|
I use treecontrol to build a tree, it is a 3 level tree has one root node ,there are several children nodes which is under root node, and some leaf nodes are under children nodes,but some are not, they are under root nodes. for each level node I have a popup menu, but for the leaf node which is under the root node, it can't tell which menu it should popup.
In the code I set up a level_num to decide which node popup what kind of menu,but leaf node in the children level,it has same level_num of children node,so could anyone can help?
if(iCode)
{
if(level_num == 4)
m_Menu.LoadMenu( IDR_DELETE_SUBPRJ) ;
if(level_num == 3)
m_Menu.LoadMenu( IDR_ADD_SUBPRJ);
if(level_num == 2)
m_Menu.LoadMenu( IDR_ADD_GROUP);
p_Menu = (CMenu*) m_Menu.GetSubMenu(0);
if( p_Menu != NULL)
p_Menu->TrackPopupMenu( TPM_RIGHTBUTTON|TPM_LEFTALIGN, pos.x, pos.y, this);
p_Menu = NULL;
}
|
|
|
|
|
You could always check the level of the parent node. Alternatively make sure that each node has a level which actually matches its real level in the tree.
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
I'v already solved it,I use setItemData to assign a enum variable when I initial the tree nodes, so when I need to decide which menu should be popped up I use getItemData to get that enum variable to decide.
Thank you anyway
|
|
|
|
|
Hi all,
on NM_CLICK i have process the lit item and it takes some time,at this time when i click on the list ctrl whether it disable its working and the click goes in message queue so when 1st click process ends those cilcks automatically perform their action.
i just want to avoid this message queue,
i want no click goes in message queuq while the process is not finish.
please help me how can i do this.
thanks in advance.
|
|
|
|
|
You may disable the list control window while performing time consuming tasks. With disabled windows, mouse and keyboard input is ignored:
CMyListCtrl::OnNMClick(NMHDR * pNMHDR, LRESULT *pResult)
{
CWaitCursor wait;
EnableWindow(0);
EnableWindow(1);
*pResult = 0;
}
|
|
|
|
|
i have already tried this,
but same same situation occur here
while list is disabled ,when click on list control that time the click event not working but after ending of previous process this event work.
|
|
|
|
|
Hi all,
I'm trying to use EnumFontFamiliesEx to get all the fonts on a Windows 7 system, and it only returns one font: "System".
I tried to follow the incomplete documentation for this function here: http://msdn.microsoft.com/query/dev10.query?appId=Dev10IDEF1&l=EN-US&k=k%28%22WINGDI%2fENUMFONTFAMILIESEX%22%29;k%28ENUMFONTFAMILIESEX%29;k%28DevLang-%22C%2B%2B%22%29;k%28TargetOS-WINDOWS%29&rd=true[^]
but with no luck. Here's my function (in a dialog-based MFC app):
void CAllFontsDlg::fillListBoxWithFonts ()
{
lb = (CListBox*) GetDlgItem (IDC_LIST1);
CDC* pDC = GetDC ();
LOGFONT lf;
lf.lfFaceName[0] = '\0';
lf.lfCharSet = DEFAULT_CHARSET;
HRESULT hr;
hr = EnumFontFamiliesEx (pDC->m_hDC, &lf, EnumFontFamExProc, 0, 0);
}
And here's my callback function (which is called exactly once):
CListBox* lb;
int CALLBACK EnumFontFamExProc(
const LOGFONT *lpelfe,
const TEXTMETRIC *lpntme,
DWORD FontType,
LPARAM lParam)
{
lb->AddString (lpelfe->lfFaceName);
return 0;
}
Can anyone see what I'm doing wrong? Thanks!
"Microsoft -- Adding unnecessary complexity to your work since 1987!"
|
|
|
|
|
Solved my own problem! The "return 0" in the callback function was terminating the enumeration the first time through! My fault...
"Microsoft -- Adding unnecessary complexity to your work since 1987!"
|
|
|
|
|
can any one explain why this code...
#include <boost\logic\tribool.hpp>
using namespace boost;
using namespace std;
tribool test1();
tribool test2();
int _tmain(int argc, _TCHAR* argv[])
{
if( !test1() || !test2() )
cout << "test failed" << endl;
return 0;
}
tribool test1()
{
cout << "test1" << endl;
return true;
}
tribool test2()
{
cout << "test2" << endl;
return false;
}
gives the following output..
test2
test1
test failed
According to the documentation on the || operator the
The operands of logical-AND and logical-OR expressions are evaluated from left to right. If the value of the first operand is sufficient to determine the result of the operation, the second operand is not evaluated. This is called "short-circuit evaluation." There is a sequence point after the first operand. See Sequence Points for more information.
I fixed the "bug" by changing my if statement to
if( !static_cast<bool>(test1()) || !static_cast<bool>(test2()) )
I did notice in the disassembly that the boost function boost::logic::operator|| was being called and wonder if this what was effecting my logic.
Thanks in advance
Thanks,
Robin.
|
|
|
|
|
Unless I'm missing something, the if check should resolve to ( false || true ) which resolves to true and so the test failed should be the output.
Now I see what I was missing.
You are wondering why the call to test2 occurs first? My guess would be that the documentation is only for the intrinsic types of the language and the "tribool" may implement it's own || operator.
Chris Meech
I am Canadian. [heard in a local bar]
In theory there is no difference between theory and practice. In practice there is. [Yogi Berra]
posting about Crystal Reports here is like discussing gay marriage on a catholic church’s website.[Nishant Sivakumar]
|
|
|
|
|
Looking further in to the tribool header file there is an overload for the || operator (and && operator) I am yet to look further into it to work out which parameter is which in the overload.
I would of thought that an overridden || operator would or at least should work in the same way as it does with intrinsic types.
Thanks,
Robin.
|
|
|
|
|
The parsing and evaluation of the if construct probably implements some kind of LIFO stack and that is why you see test2 called before test1. But it is odd behaviour.
Chris Meech
I am Canadian. [heard in a local bar]
In theory there is no difference between theory and practice. In practice there is. [Yogi Berra]
posting about Crystal Reports here is like discussing gay marriage on a catholic church’s website.[Nishant Sivakumar]
|
|
|
|
|
Wow, that's interesting.
Veni, vidi, vici.
|
|
|
|
|
It is yes and it was very confusing as I had similar code relating to comms where I was doing something like:
if( !unit.Connected() || !unit.IsTypeA()
{
PrintFailMessage( "Failed to connect" );
}
and this worked just fine, but due to other reasons I changed my return type for the functions to boost::tribool and all of a sudden the IsTypeA() function was getting called first. Had me going for ages.
Thanks,
Robin.
|
|
|
|
|
Robin Imrie wrote: all of a sudden the IsTypeA() function was getting called first
Thats a good reason for changing the code to
bool bConnected = unit.Connected();
bool bIsTypeA = unit.IsTypeA();
if ( !bConnected || !bIsTypeA )
{
PinrFailMessage( "Failed to connect" );
}
This will ensure that the call to Connected is always made first, regardless of what type is used for the return value.
Chris Meech
I am Canadian. [heard in a local bar]
In theory there is no difference between theory and practice. In practice there is. [Yogi Berra]
posting about Crystal Reports here is like discussing gay marriage on a catholic church’s website.[Nishant Sivakumar]
|
|
|
|
|
Hi,
I am using one dll to load an image. I want to apply an effect which exists in another dll. I want to synchronize betwenn these two dlls.
I have one dialog box and one picture control. I'll load an image using FreeImage Dll. Now I an using Magick++ Dll to apply an effect on that Image which is loaded using FreeImage Dll. I am able to do that. I'll take a reference to that instance of loaded image, apply effect using Magick++ dll. My problem is after applying the effect, I have to save the image to some memory location. Again using FreeImage dll to load the effected Image.
I want to apply the effect on the Image using second dll on run time. without saving the image, image should get updated when the user drags the slider.
Please let me know if the above question is not clear.
If understood, any help will be appreciated.
If u have any sample code to synchronize two dlls functionality, it will be of great help.
Regards,
mbatra
|
|
|
|
|
You don't "share" or synchronize data or functionalities between DLLs.
Your application will load an image with FreeImage into its own format (FIBITMAP); from there, you can convert that into a HBITMAP (just google it)
When wanting to call some Magick++ functions you will have to convert the FIBITMAP data to something that it can understand (there must be an API in Magick++ to convert HBITMAP or a DIB to an Image or a BLOB) .
Good luck.
Watched code never compiles.
|
|
|
|
|
Hi Maximilien,
Thanx for your reply,
I just want to ask can I use some kind of syncronization mechanism, as after taking reference to the image loaded with FreeImage, I am applying the effcet using Magick++. its done.
I have one dialog Box (called A) on which Image is loaded using FreeImage. I'll invoke a dialog box ( called B) which has one slider control. After changing the position of the slider control, I am passing the value of slider control to parent dialog box. That effect gets applied to the image but Image gets saved to memory location. Again I'll load the Image with FreeImage.
I want before saving the Image, the effect should be visible on the Image, I want when the user drags the slider control, at the same time, value should get passed to the another dialog.
Apologize if content is not understood.
Please let me know if u need any further clarification.
Please let me know if anybody have any idea.?
Regards,
mbatra
|
|
|
|
|
I want to export some functions with Dll.
The Source File:
void Fun(std::wstring)
{
}
The def file:
LIBRARY Standby
EXPORTS
Fun
But when I load the dll with
LoadLibary , I get STL crash message.
When I switch the parameter type to basic
C types: such as
int ,
char ,
int* . Everything is OK.
I wonder whether can I use STL param type in Dll.
Any one can help me?
|
|
|
|
|
See, for instance, here[^].
Veni, vidi, vici.
|
|
|
|
|
Falconapollo wrote: I get STL crash message. Please don't assume that we can guess which message you are talking about. Unless you give the exact details of the message, and the line of code that caused the error it's impossible to give any useful suggestions.
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
hi all,
i m using IPreviewHandlerto create preview of diffrent type of files,but some application stop working and give a crash message with Event Name : BEX,
IPreviewHandler *pHandle;
IInitializeWithFile *m_IFile;
IInitializeWithStream *m_IStream;
IStream *pStream;
if(pHandle != NULL)
{
if(m_IFile!=NULL)
{
m_IFile->Release();
m_IFile = NULL;
}
if(m_IStream!=NULL)
{
m_IStream->Release();
m_IStream = NULL;
}
if(m_pStream != NULL)
{
m_pStream->Release();
m_pStream = NULL;
}
pHandle->Unload();
pHandle->Release();
pHandle = NULL;
CoUninitialize();
}
HRESULT hres;
WCHAR *pwcExtn = NULL;
CString csClsid;
pwcExtn = StrRChr(szFile, NULL, L'.');
csClsid = GetClsidFromExtn( pwcExtn );
CLSID cls;
pHandle = NULL;
m_IFile = NULL;
m_IStream = NULL;
pStream = NULL;
if(CLSIDFromString( (LPWSTR)(LPCTSTR)csClsid,&cls) != NOERROR )
{
return 0;
}
else
{
CoInitialize(NULL);
hres = CoCreateInstance(
cls,
0,
CLSCTX_INPROC_SERVER | CLSCTX_LOCAL_SERVER,
IID_IPreviewHandler,(LPVOID*)&pHandle);
if (FAILED(hres))
{
CoUninitialize();
return 0;
}
hres = pHandle->QueryInterface(IID_IInitializeWithFile,(LPVOID*)&m_IFile );
if (FAILED(hres))
{
hres = pHandle->QueryInterface(IID_IInitializeWithStream,(LPVOID*)&m_IStream );
if (FAILED(hres))
{
CoUninitialize();
return 0;
}
if(CreateStreamOnHGlobal(NULL, TRUE, &pStream) == S_OK)
{
CFileException pError ;
CFile picFile;
if(picFile.Open(szFile, CFile::modeRead | CFile::typeBinary,&pError))
{
BYTE pBuffer[1024];
UINT uiRead = 0;
while((uiRead = picFile.Read(pBuffer, sizeof(pBuffer))) != 0)
{
ULONG ulWritten = 0;
pStream->Write(pBuffer, uiRead, &ulWritten);
}
picFile.Close();
}
else
{
TCHAR szError[1024];
pError.GetErrorMessage(szError, 1024);
AfxMessageBox(szError);
}
}
m_IStream->Initialize(pStream,STGM_READ);
}
else
hres = m_IFile->Initialize(szFile,STGM_READ);
hres = pHandle->SetWindow( hWnd , &rectPreview );
pHandle->DoPreview();
pHandle->SetRect(&rectPreview);
}
i really dont understand whats happning here.
please help me for this.
|
|
|
|
|
Hoping to get some help from the experts here. I have a service, "Listener", that is listing on 0.0.0.0:7070. I have another application, "Agent" that receives fully-formed UDP/IP packets via a proprietary interface.
I would like to preserve the UDP/IP packet in its entirety (do not want to perform any NAT) and somehow get it from the Agent to the Listener.
Current setup:
Physical NIC with address 10.80.8.10 / 255.255.0.0
Microsoft Loopback Adapter with address 10.10.10.1 / 255.255.0.0
IP Forwarding enabled via Registry Edit (Windows XP / 7)
The IP packet that the Agent has received is addressed to 10.10.10.1:7070 (Virtual NIC).
What I can get to work:
Using WinPcap and WinPcap::SendPacket, I can attach to the Physical NIC and send the packet to that NIC. The packet is then forwarded to the Virtual NIC (I assume) and received by the Listener.
Problem: My target system does not have a Physical NIC
I tried installing a 2nd Microsoft Loopback Adapter, mimicking the addresses of the Physical NIC, attaching WinPcap to the 2nd Loopback Adapter, and sending the packet to it, just like I did with the Physical NIC, and... nothing. I've also tried experimenting with sending it to a Raw Socket, with no results (not sure if I'm doing something wrong, have never used raw sockets before).
So, I'm hoping someone can point me in the right direction. End goal is to get the pre-formed packet from the Agent to the Listener, and I really don't care what the mechanism is (WinPcap, Raw Sockets, something simple I'm too ignorant to know about, anything else), so long as the Listener receives the packet and the IP/UDP headers and Data payload are unmolested.
Cheers,
Chris
|
|
|
|
|
Hi!
How can I pass a string array to an LPARAM parameter in C++?
I've tried a
std::list<std::basic_string<TCHAR> type but my program crashes when I cast the values:
string_list szFile = (string_list) ppsp->lParam;
Thanks in advance.
|
|
|
|
|
What is string_list , and what does ppsp point to? There is so much detail missing from your question it's impossible to guess what the problem is.
One of these days I'm going to think of a really clever signature.
|
|
|
|
|