windows - CreateDialogParam 从不调用 WM_INITDIALOG

标签 windows dialog

我在 .rc 文件中定义了一个对话框:

IDD_DIALOG_AUTHENTICATION DIALOGEX 0, 0, 214, 138
STYLE DS_SETFONT | DS_MODALFRAME | DS_SETFOREGROUND | DS_3DLOOK | DS_FIXEDSYS | WS_POPUP | WS_VISIBLE | WS_CAPTION
CAPTION "Dialog"
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
    DEFPUSHBUTTON   "Validate",ID_BTN_VALIDATE,102,117,50,14
    PUSHBUTTON      "Exit",ID_BTN_EXIT,157,117,50,14
    LTEXT           "Username",IDC_STATIC,7,9,45,8
    CONTROL         "<a>SysLink</a>",IDC_SYSLINK,"SysLink",WS_TABSTOP,7,99,60,14
    LTEXT           "Password",IDC_STATIC,7,25,45,8
    LTEXT           "messages",IDC_MESSAGE,7,39,197,55
    EDITTEXT        IDC_USERNAME,44,7,140,14,ES_AUTOHSCROLL
    EDITTEXT        IDC_PASSWORD,44,22,140,14,ES_PASSWORD | ES_AUTOHSCROLL
END

ID 是“IDD_DIALOG_AUTHENTICATION”。 CreateDialogParam 被称为:

HWND hDlgWnd = CreateDialogParamW(GetModuleHandle(NULL),L"IDD_DIALOG_AUTHENTICATION", (DLGPROC)dialogProc, (LPARAM)this);

但它返回空 HWND 和 NO 错误代码 (GetLastError() == 0)。

有几条消息发送到我的 dialogProc 函数,但从不 WM_INITDIALOG(消息是 WM_SETFONT、0x0090 (??)、WM_DESTROY 和 WM_NCDESTROY)

操作系统是 Vista 32 位(无 SP)。

有什么想法吗??

已编辑:好的,罪魁祸首是 SysLink 控件。没有它,我会收到 WM_INITDIALOG 消息,并且对话框正常显示。

但是,由于需要 SysLink 控件,我: 1. 将可执行文件与 comctl32.lib 链接 2.用ICC_LINK_CLASS调用InitCommonControlsEx

但是,InitCommonControlsEx 失败,即返回 FALSE,所以现在的问题是如何让 SysLink 控件显示...:)

最佳答案

所有你需要的是

#if defined _M_IX86
  #pragma comment(linker, "/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='x86' publicKeyToken='6595b64144ccf1df' language='*'\"")
#elif defined _M_X64
  #pragma comment(linker, "/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='amd64' publicKeyToken='6595b64144ccf1df' language='*'\"")
#else
  #pragma comment(linker, "/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")
#endif

在你的 stdafx.h 文件中。 或者只是将依赖于“Microsoft.Windows.Common-Controls”的 list 添加到您的项目中。

关于windows - CreateDialogParam 从不调用 WM_INITDIALOG,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6355560/

相关文章:

windows - Cygwin 安装 : Missing/usr/bin and/usr/local/sbin directories

c++ - 如何获取hook winapi函数的调用后参数?

jqueryui 打开多个对话框;应该只打开一个

c++ - 日期和时间选择器问题,无法重置日期或时间

python - 派生自 wx.Dialog 的通用 MessageBox

c - 不使用命令行窗口打开program.exe

windows - 如何从 jenkins 访问 npm git 依赖项?

python - 在 Windows 10 上安装 Keras 时出现编码错误

c++ - 当我使用 C++ win32 API 单击确定按钮时,如何隐藏当前窗口?

android - 自定义对话框中的 ImageView - fill_parent 不起作用,我的对话框很小