Sign in to follow this  
michaelj

WIN32 CreateDialog problem!

Recommended Posts

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.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this