LPCTSTR parameters in Windows API and MAKEINTRESOURCE usage
Posted on 2003-03-11
I previously answered a question about a dialog that won't display, because the calling function was specifying the dialog template name as a string. I remembered I had this problem quite a few times and only using MAKEINTERESOURCE(RESOURCE_ID) would solve the problem.
Wherever resources are involved through the API, LPCTSTR paramters are present in the functions that can receive either a string with the name of the resource (the Dialog Template __name__, in the case above) or the result of the MAKEINTERESOURCE macro.
Looking at the macro, it *seems* to convert the integer ID of a resource to a string, representing the resource name.
If this is the case, how this differs from sending the plain resource name to, let's say, DialogBox function?
When having a dialog with the resource ID of "IDD_DIALOG1", calling
DialogBoxA(hInstance,"IDD_DIALOG1",...) will fail, whereas
DialogBoxA(hInstance,MAKEINTRESOURCE(IDD_DIALOG1),...) will succeed.
The documentation for DialogBox states clearly that the template name can be used to identify the dialog box template. Isn't that the name in the resource? I tried to find the name "IDD_DIALOG1" in the binary resource but found nothing there (Unicode or ASCII) so I am a bit confused about this.
Can anybody shed a bit of light on this? I get the feeling that I am missing something very basic here...