This topic is now archived and is closed to further replies.


need help in win32 programming

Recommended Posts

Hi! im trying to create modal dialogbox on run-time , and this is the code im using: DLGTEMPLATE dTemplate; = WS_POPUP | WS_SYSMENU | WS_CAPTION | WS_VISIBLE; dTemplate.cdit = 0; = 450; =100; dTemplate.x =0; dTemplate.y =0; DialogBoxIndirect(CApp.GetHInst(),&dTemplate,CApp.GetHWnd(),(DLGPROC)DlgProc8); while CApp.GetHWnd() is the parent hwnd and CApp.GetHInst is the parent instance when im trying to create the dialog in that way i get this error: ERROR_RESOURCE_NAME_NOT_FOUND somebody knows why? thanks . roy.

Share this post

Link to post
Share on other sites
According to my copy of the MSDN Library "DLGTEMPLATE structure is always immediately followed by three variable-length arrays that specify the menu, class, and title for the dialog box." In your code you seem to be forgetting to take care of these "variable-length arrays".

Here is how the MSDN Library handles them:

lpw = (LPWORD) (lpdt + 1);
*lpw++ = 0; // no menu
*lpw++ = 0; // predefined dialog box class (by default)

lpwsz = (LPWSTR) lpw;
nchar = 1+ MultiByteToWideChar (CP_ACP, 0, "My Dialog",
-1, lpwsz, 50);
lpw += nchar;

lpw is a LPWORD, lpwsz is a LPWSTR, and lpdt is a LPDLGTEMPLATE. Obviosly they dynamically allocate the DLGTEMPLATE structure and you would need to alter the code to adjust for the fact that you do not.

Share this post

Link to post
Share on other sites