[b][red]This message was edited by Flack at 2003-4-25 12:30:15[/red][/b][hr]
I have a MFC dialog app that I created with VC++ AppWizard.
Now, from my original dialog box, I want to create a new one, which appears as a separate popup. However, the code I have does not work (probably because it's totally wrong).
Anyway, here is the code (this code is in a function I call when a button is pushed):
myTemplate.style = WS_POPUP|WS_VISIBLE|LBS_STANDARD;
myTemplate.dwExtendedStyle = NULL,
myTemplate.cdit = 0;
myTemplate.x = 10;
myTemplate.y = 10;
myTemplate.cx = 100;
myTemplate.cy = 100;
int nBufferSize = sizeof(DLGTEMPLATE);
HLOCAL hLocal = LocalAlloc(LHND, nBufferSize);
BYTE* pBuffer = (BYTE*)LocalLock(hLocal);
BYTE* pdest = pBuffer;
// transfer DLGTEMPLATE structure to the buffer
memcpy(pdest, &myTemplate, sizeof(DLGTEMPLATE));
Now, the InitModalIndirect returns a nonzero value,indicating that the dialog object was created and initialized successfully. However, the line myDialog.DoModal()(red line) returns a -1 indicating failure. Does anyone know what I am doing wrong?
My goal is to eventually have a separate dialog popup that contains a list box but I can't even get an empty dialog window to appear.
Thanx for the help,