|
发表于 2019-5-30 16:57:28
|
显示全部楼层
MSDN描述
INT_PTR DialogBoxIndirectParamA(
HINSTANCE hInstance,
LPCDLGTEMPLATEA hDialogTemplate,
HWND hWndParent,
DLGPROC lpDialogFunc,
LPARAM dwInitParam
);
If the function fails because the hWndParent parameter is invalid, the return value is zero.
The function returns zero in this case for compatibility with previous versions of Windows.
If the function fails for any other reason, the return value is –1.
To get extended error information, call GetLastError.
如果函数失败,因为hWndParent 参数不合法,返回值为 0,这时兼容先前windows版本。
如果其它原因,返回值为-1,要获取更多的错误信息,调用GetLastError()
你应该用GetLastError()确认具体错误。
还有这些关于对话框模板的要求。
In a standard dialog box template, the DLGTEMPLATE structure and each of the DLGITEMTEMPLATE structures must be aligned on DWORD boundaries. The creation data array that follows a DLGITEMTEMPLATE structure must also be aligned on a DWORD boundary. All of the other variable-length arrays in the template must be aligned on WORD boundaries.
In an extended dialog box template, the DLGTEMPLATEEX header and each of the DLGITEMTEMPLATEEX control definitions must be aligned on DWORD boundaries. The creation data array, if any, that follows a DLGITEMTEMPLATEEX structure must also be aligned on a DWORD boundary. All of the other variable-length arrays in the template must be aligned on WORD boundaries.
All character strings in the dialog box template, such as titles for the dialog box and buttons, must be Unicode strings.
你那temp->cx=0.temp->cx=0,宽高都为0,即使正确窗口也没法显示。
再看
void DialogBoxA(
HINSTANCE hInstance,
LPCTSTR lpTemplate,
HWND hWndParent,
DLGPROC lpDialogFunc
);
参数:
HINSTANCE
A handle to the module which contains the dialog box template. If this parameter is NULL, then the current executable is used.
包含对话框模板模块的句柄。如果为NULL,用当前执行地。
你执行在线程里,而资源在APP里,线程里,它怎么能找到。把app里的HINSTANCE 弄过来吧,不能为NULL。
也可用GetModuleHandle(NULL)试试吧。只是不知道在你那行不行。它必须是包含资源的句柄。
|
|