WIN32 CreateDialog problem!

Started by
1 comment, last by ApochPiQ 17 years, 10 months ago
I want to show a dialog bar in a win32 window, so I do this: ************** case ID_TEST_CREATE_DIALOG: { HWND hdlg = CreateDialog(hInst, "DIALOG_A", hMainWnd, (DLGPROC)DialogProcDiaglog1); ShowWindow(hdlg, SW_SHOW); } break; ************** But it doesn't work, the dialog isn't created. when using MAKEINTRESOURCE(IDD_DIALOG_A), it works well and the dialog is created. I wonder how to specify the dialog box template's name?? The following is MSDN's content on this API: HWND CreateDialog(HINSTANCE hInstance, LPCTSTR lpTemplate, HWND hWndParent, DLGPROC lpDialogFunc ); and it explains the "LPCTSTR lpTemplate" parameter: This parameter is either the pointer to a null-terminated character string that specifies the name of the dialog box template or an integer value that specifies the resource identifier of the dialog box template.
Advertisement
If you want to specify the name of the dialog as a string, you need to name the dialog resource with a string. Otherwise use a symbolic constant and use the MAKEINTRESOURCE macro. You can't interchange the two.
To elaborate a bit, IDD_DIALOG_A is just a macro that is replaced with a numeric ID when your EXE is compiled. You can see this by viewing the resource.h file by hand, or by opening the final EXE file in a resource editor.

As the AP said, you will need to either manually name the resource with a string, or use MAKEINTRESOURCE.

Wielder of the Sacred Wands
[Work - ArenaNet] [Epoch Language] [Scribblings]

This topic is closed to new replies.

Advertisement