Dialog box troubles...

Started by
1 comment, last by mrmrcoleman 18 years, 4 months ago
Hello, I am trying to add a simple dialogbox to my application. I am using VC++6. After inserting the new resource (insert->resource) I then save the script and include resource.h. However when I call the DialogBox method like so: DialogBox(hInstance, TEXT("IDD_DIALOG1"), g_hWnd, AdministratorDialogProc) (Where IDD_DIALOG1 is the ID of the dialog box) the method fails. GetLastError returns 1812, or 1814. ERROR_RESOURCE_DATA_NOT_FOUND 1812 The specified image file did not contain a resource section. ERROR_RESOURCE_NAME_NOT_FOUND 1814 The specified resource name cannot be found in the image file. I have tried this over and over again and I can't get it to work. Can anyone see what I might be doing wrong? Thanks in advance, Mark
Advertisement
Yes. You misinterpreted the parameters for DialogBox. The resource (IDD_DIALOG) is a constant for an integer value, not a string. You should use the MAKEINTRESOURCE macro to obtain the right parameter for DialogBox:
DialogBox(hInstance, MAKEINTRESOURCE(IDD_DIALOG1), g_hWnd, AdministratorDialogProc)

See MSDN as well.

Illco
Illco,

Thank you so much. That has been bugging me for hours. I don't know how I missed that, probably because I was learning from a few different sources.

Thanks again,

Mark

This topic is closed to new replies.

Advertisement