Dialog box troubles...

This topic is 4357 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

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

Share on other sites
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

Share on other sites
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

Share on other sites

This topic is 4357 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Create an account

Register a new account

• Forum Statistics

• Total Topics
628688
• Total Posts
2984243

• 16
• 13
• 13
• 10
• 10