Problem with CDialog::InitModalIndirect()
-
I'm wrote a simple code to creates a empty Dialog. But I've an exception with him. Why?
DLGTEMPLATE dlg; dlg.x = 0; dlg.y = 0; dlg.cx = 200; dlg.cy = 200; dlg.style = WS\_BORDER|WS\_CHILD|WS\_VISIBLE; dlg.dwExtendedStyle = 0; dlg.cdit = 0; CDialog Dialog; Dialog.InitModalIndirect(&dlg); DoModal();
Best regards, Eugene Pustovoyt
ICQ UIN: 161325180
-
I'm wrote a simple code to creates a empty Dialog. But I've an exception with him. Why?
DLGTEMPLATE dlg; dlg.x = 0; dlg.y = 0; dlg.cx = 200; dlg.cy = 200; dlg.style = WS\_BORDER|WS\_CHILD|WS\_VISIBLE; dlg.dwExtendedStyle = 0; dlg.cdit = 0; CDialog Dialog; Dialog.InitModalIndirect(&dlg); DoModal();
Best regards, Eugene Pustovoyt
ICQ UIN: 161325180
From MSDN: "To create a modal dialog box indirectly, first allocate a global block of memory and fill it with the dialog box template. Then call the empty CDialog constructor to construct the dialog-box object. Next, call InitModalIndirect to store your handle to the in-memory dialog-box template." Here is the most IMPORTANT part: "first allocate a global block of memory" It does not matter which version of InitModalIndirect you call, the DLGTEMPLATE must be in a globaly allocated memory block. That means using GlobalAlloc(...). If this is not the cause of exception, then the MSDN remarks section may be wrong. The only question that remains is: who is responsible for freeing the memeory? Search the MSDN for the sample code: "DLGTEMPL: Creating Dialog Templates Dynamically" Good Luck! INTP "The more help VB provides VB programmers, the more miserable your life as a C++ programmer becomes." Andrew W. Troelsen