?
Solved

Handling ID_APP_EXIT message.

Posted on 2000-03-21
4
Medium Priority
?
871 Views
Last Modified: 2013-11-20
I'm trying to write a routine which will prompt the user to save
an unsaved document (I'm not using the serialize functions).  

I'd like the routine to simply check a boolean (which is in the document
class) and then call my OnFileSave routine (in the document class)
if needed.

I'm trying to have the ID_APP_EXIT message handled in the document
class.  The problem is that after this message has been handled, I
would still like to exit the application.  How do I do this?  I can't
seem to be able to call the CWinApp:ExitInstance() function from
the document class.

The other approach would be to handle the ID_APP_EXIT message
in the application class, but I would somehow need to get it
to call my save function in the document class.

What's my best course of action?
0
Comment
Question by:mosaicer
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 22

Expert Comment

by:CJ_S
ID: 2641907
PostQuitMessage(0);

or does that not work in MFC? Stupid MFC =(....laughs, try it mate, it works in win32, so maybe you are lucky.
0
 
LVL 23

Accepted Solution

by:
chensu earned 200 total points
ID: 2642036
::AfxGetMainWnd()->PostMessage(WM_CLOSE);
0
 

Author Comment

by:mosaicer
ID: 2642055
Thanks!

0
 

Expert Comment

by:yaoliwei
ID: 2648120
CWnd* pwndMain = (CWnd*)AfxGetMainWnd();
pwndMain->SendMessage (WM_CLOSE,0,0);


By the way the comment of "CJ S" is not a good method which will cause a memory leak.


0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses
Course of the Month10 days, 12 hours left to enroll

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question