CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Jul 2006
    Posts
    285

    [RESOLVED] Exit message

    Hi
    I wanna sk something more:
    I want my application when user press EXIT button give him the choise to cancel or continue exit.
    For example:

    "You sure wanna exit";
    OK CANCEL

    Any code ideas;

  2. #2
    Join Date
    May 2005
    Posts
    4,954

    Re: Exit message

    Look at ::MessageBox().

    Cheers
    If a post helped you dont forget to "Rate This Post"

    My Article: Capturing Windows Regardless of Their Z-Order

    Cheers

  3. #3
    Join Date
    Dec 2008
    Posts
    29

    Re: Exit message

    Code:
    case WM_CLOSE :
          if (IDYES == MessageBox (hwnd, TEXT ("Really want to close?"),
                                saName, MB_YESNO | MB_ICONQUESTION) )
              return 1 ;
          else
              return 0 ;
    you can use WM_QUERYENDSESSION too.
    Last edited by codecX; December 10th, 2008 at 03:24 AM.

  4. #4
    Join Date
    Jul 2006
    Posts
    285

    Re: Exit message

    I think your code is wrong

  5. #5
    Join Date
    Dec 2003
    Location
    Syracuse, NY
    Posts
    400

    Re: Exit message

    In WM_CLOSE in your window procedure you can do:

    Code:
    case WM_CLOSE:
    {
        if (MessageBox(hWnd, "Are You Sure You Want To Exit?", "Exit", MB_YESNO) == IDYES)
        {
            PostQuitMessage(0);
        }
        else
            return 0;
    }break;
    "Windows programming is like going to the dentist: You know it's good for you, but no one likes doing it."
    - Andre LaMothe

    DLL For Beginners(UPDATED)
    Please use CODE tags
    Rate me if I've helped.

  6. #6
    Join Date
    Jul 2006
    Posts
    285

    Re: Exit message

    Ok thanks i finally did it like this:

    if
    (MessageBox(NULL,"Are You Sure You Want To Exit?", "Exit", MB_YESNO) == IDYES)
    {
    ShowMessage("Thank You");
    PostQuitMessage(0);

    }

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured