Click to See Complete Forum and Search --> : Dynamic Dialogs!!


Pravish
January 14th, 2008, 01:19 PM
hey, I m using DLGTEMPLATE structure for creating dialog template in memory.
OnCommand() the following function is suppose to create the dialog in memory. Although (digparam!=0)i.e. the DialgoBoxIndirect() succeeds(presumably), the dialog doesnt show up. any ideas why?

INT_PTR MyDynamicDlg(HWND hWnd)
{

LPDLGTEMPLATE pDlg = new DLGTEMPLATE;


HINSTANCE hInstance = (HINSTANCE)GetModuleHandle(NULL);
pDlg->style = WS_CHILD | WS_VISIBLE | WS_OVERLAPPED;
pDlg->dwExtendedStyle = NULL;
pDlg->cdit = 5;
pDlg->cx = 200;
pDlg->cy = 200;
pDlg->x = 0;
pDlg->y = 0;


INT_PTR dlgparam = DialogBoxIndirect(
hInstance,//HINSTANCE hInstance,
pDlg,//LPCDLGTEMPLATE lpTemplate,
hWnd,//HWND hWndParent,
(DLGPROC)MyDlgProc//DLGPROC lpDialogFunc
);

if(dlgparam == 0)
MessageBox(hWnd,"No dialog created","NO DLG", MB_OK);
return dlgparam;
}

kirants
January 14th, 2008, 02:07 PM
Have you checked dlgparam against -1 ?
If the function fails for any other reason, the return value is –1.To get extended error information, call GetLastError.

Pravish
January 15th, 2008, 03:16 AM
Yea u are write. With GetLastError I get 1812. What do I do?

Pravish
January 15th, 2008, 03:37 AM
The specified image file did not contain a resource section. ??

Igor Vartanov
January 15th, 2008, 05:18 AM
The specified image file did not contain a resource section. ??Yep. :)

You specify your dialog contains 5 controls, but your bare template does not contain any essential data - neither menu description, nor dialog class specification, nor dialog item definitions (see DLGTEMPLATE Structure (http://msdn2.microsoft.com/en-us/library/ms645394(VS.85).aspx) Remarks section.)

Please see my sample for empty dialog.

BTW, I believe you poorly understand WS_CHILD style. This style must be used only when dialog window becomes a child "control" window for parent window, and therefore it never could be used for DialogBoxXxx function family.

Pravish
January 15th, 2008, 11:58 AM
Oh Gr8, Thanks for the help sir. THanks a ton!