Exiting a program

This is a discussion on Exiting a program within the Windows Programming forums, part of the Platform Specific Boards category; Im working on this program,and when the user exits by clicking exit it should say do you wish to exit? ...

  1. #1
    Registered User
    Join Date
    May 2004
    Posts
    215

    Exiting a program

    Im working on this program,and when the user exits by clicking exit it should say do you wish to exit? and the user should be able to click yes or no. But lets say the user clicks the X at the upper right hand part of their screen to exit the program, it doesnt do that. Does anyone know how to make something happen if the user tries to exit by clicking the X and the upper right hand part of the screen?

  2. #2
    Registered User Bajanine's Avatar
    Join Date
    Dec 2001
    Location
    The most peaks over 10,000 feet!
    Posts
    396
    How about something like this:

    Code:
    case WM_DESTROY:  
    		if(bFileNeedsSaved == true)
    		{
    			int answer;
    			answer = MessageBox (NULL, TEXT ("Do you want to save your changes?"), 
    				TEXT ("File has been modified!"), MB_YESNOCANCEL);
    			if(answer==IDYES)
    			{
    				SendMessage(hwnd, WM_COMMAND, IDM_FILE_SAVE, 0); 
    			}
    			if(answer==IDCANCEL)
    				return 0;
    		}
    		PostQuitMessage (0);
    		return 0;
    	}
    	return DefWindowProc (hwnd, message, wParam, lParam);
    Favorite Quote:

    >For that reason someone invented C++.
    BLASPHEMY! Begone from my C board, you foul lover of objects, before the gods of C cast you into the void as punishment for your weakness! There is no penance for saying such things in my presence. You are henceforth excommunicated. Never return to this house, filthy heretic!



  3. #3
    Registered User
    Join Date
    May 2004
    Posts
    215
    thanks!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Can someome help me with a program please?
    By WinterInChicago in forum C++ Programming
    Replies: 3
    Last Post: 09-21-2006, 10:58 PM
  2. exiting program
    By ypramesh in forum C Programming
    Replies: 2
    Last Post: 04-01-2006, 02:27 PM
  3. Need help with my program...
    By Noah in forum C Programming
    Replies: 2
    Last Post: 03-11-2006, 06:49 PM
  4. Program exiting
    By sql.scripter in forum C Programming
    Replies: 9
    Last Post: 01-28-2006, 07:51 PM
  5. My program, anyhelp
    By @licomb in forum C Programming
    Replies: 14
    Last Post: 08-14-2001, 10:04 PM

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