need help in win32 programming

Started by
1 comment, last by Xeno 23 years, 8 months ago
Hi! im trying to create modal dialogbox on run-time , and this is the code im using: DLGTEMPLATE dTemplate; dTemplate.style = WS_POPUP | WS_SYSMENU | WS_CAPTION | WS_VISIBLE; dTemplate.cdit = 0; dTemplate.cx = 450; dTemplate.cy =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.

------------------------------- Goblineye Entertainment------------------------------

Advertisement
someone, please?
thanks

------------------------------- Goblineye Entertainment------------------------------

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.

This topic is closed to new replies.

Advertisement