-
Preventing Cancel?
Hi! I have created a wizard using Win32 API Property Sheets. When the user presses the "Cancel" button, I want them to be able to confirm that they actually wish to exit. I put something together that should accomplish this, but it seems that no matter whether I press the "Yes" or the "No" button the wizard still closes! Can anybody tell me how to prevent Windows from sending the cancel message or reset it?
Thanks for all of your help in advance!
Joe
-
Do you handle the cancel button press?
Do you supply the yes/no message box?
Post some code.
gg
-
From inside of the GetMessage loop:
Code:
if(hwnd && (NULL == (HWND)PropSheet_GetCurrentPageHwnd(hwnd)))
{
LRESULT lAskUsr = MessageBox(hwnd,szMbText,szMbTitle,MB_YESNO|MB_ICONQUESTION);
if (lAskUsr == IDYES)
{
DestroyWindow(hwnd);
hwnd = NULL;
PostQuitMessage(0);
}
else
{
//Cancel the cancel operation
}
}
-
Ok; I fixed it! Inside of the Dialog Procedure for each page, under "WM_NOTIFY", you need to put:
Code:
case PSN_QUERYCANCEL:
{
LRESULT lAskUsr = MessageBox(hdlg,szMbText,szMbTitle,MB_YESNO|MB_ICONQUESTION);
if (lAskUsr == IDYES)
{
SetWindowLongPtr(hdlg, DWL_MSGRESULT, FALSE);
return TRUE;
}
else
{
SetWindowLongPtr(hdlg, DWL_MSGRESULT, TRUE);
return TRUE;
}
}
break;