PSN_QUERYCANCEL 不关闭属性表
我创建了一个属性表,每个选项卡页共享相同的 pfnDlgProc
。在 pfnDlgProc
中,我有以下代码:
switch (msg) {
case WM_NOTIFY:
nmhdr = (NMHDR*)lParam;
switch (nmhdr->code) {
case PSN_QUERYCANCEL:
printf("PSN_QUERYCANCEL\n");
SetWindowLong(nmhdr->hwndFrom, DWL_MSGRESULT, FALSE);
return TRUE;
}
break;
...
}
当我单击属性表上的“取消”按钮时,会打印 PSN_QUERYCANCEL
,但属性表不会关闭。这是为什么呢?我还需要做其他事情来允许它/使其关闭吗?我知道我可以将 DestroyWindow(nmhdr->hwndFrom) 添加到处理程序,但这是正确的方法吗?
I have a property sheet that I have created and each of the tab pages share the same pfnDlgProc
. In the pfnDlgProc
, I have this code:
switch (msg) {
case WM_NOTIFY:
nmhdr = (NMHDR*)lParam;
switch (nmhdr->code) {
case PSN_QUERYCANCEL:
printf("PSN_QUERYCANCEL\n");
SetWindowLong(nmhdr->hwndFrom, DWL_MSGRESULT, FALSE);
return TRUE;
}
break;
...
}
When I click the Cancel button on my property sheet, PSN_QUERYCANCEL
is printed, but the property sheet does not close. Why is this? Is there something else I need to do to allow it to/make it close? I know I can add DestroyWindow(nmhdr->hwndFrom)
to the handler but is that the proper way to do it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您正在向您发送通知的窗口句柄上设置 DWL_MSGRESULT,但不一定是您正在为其处理 WM_NOTIFY 的对话框窗口。不要使用 nmhdr->hwndFrom 窗口句柄,而是尝试使用传递给 pfnDlgProc 的 HWND。
You are setting the DWL_MSGRESULT on the window handle that sent you the notification, but not necessarily the window that is the dialog you are processing the WM_NOTIFY for. Instead of using the nmhdr->hwndFrom window handle, try using the HWND that is passed to your pfnDlgProc.