Preventing Cancel?

This is a discussion on Preventing Cancel? within the Windows Programming forums, part of the Platform Specific Boards category; Hi! I have created a wizard using Win32 API Property Sheets. When the user presses the "Cancel" button, I want ...

  1. #1
    Registered User
    Join Date
    Dec 2003
    Posts
    13

    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

  2. #2
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,701
    Do you handle the cancel button press?
    Do you supply the yes/no message box?
    Post some code.

    gg

  3. #3
    Registered User
    Join Date
    Dec 2003
    Posts
    13
    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
      }      
    }

  4. #4
    Registered User
    Join Date
    Dec 2003
    Posts
    13
    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;

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. General Guidelines on Preventing Header File collision
    By stanlvw in forum C++ Programming
    Replies: 12
    Last Post: 07-05-2008, 05:02 AM
  2. cancel a DLL call
    By ryan_germain in forum Windows Programming
    Replies: 10
    Last Post: 08-08-2006, 07:48 AM
  3. GetOpenFileName: tell if the user pressed cancel
    By SwiftOutlaw in forum Windows Programming
    Replies: 1
    Last Post: 11-11-2004, 03:48 PM
  4. Cancel Button not working
    By Xzyx987X in forum Windows Programming
    Replies: 3
    Last Post: 10-27-2004, 01:41 AM
  5. Cancel WaitCommEvent on win2k?
    By yoxler in forum Windows Programming
    Replies: 0
    Last Post: 05-08-2003, 01:34 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21