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 开发者_StackOverflow中文版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?
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.
精彩评论