?
Solved

terminating application

Posted on 1998-10-07
2
Medium Priority
?
192 Views
Last Modified: 2013-11-20
Hi guys,


I would like to know how to terminate a MFC application. The problem is that I want to terminate it when the main window is isn´t created (at start). In fact the point of interest is in the InitialUpdate method of my View. I´ve already tried "AfxGetMainWnd()->SendMessage(WM_CLOSE)" but this gave me AV maybe because there is no main wnd at this time.

Thank you

Nick
0
Comment
Question by:nl1545
2 Comments
 
LVL 3

Expert Comment

by:plaroche
ID: 1323059
You want your application to terminate gracefully?

Why is it your view that checks for normal/abnormal?  If you could place your check somewhere else it might be a lot easier to terminate the application. This is due to the way/order that the doc/view/frame are created.
0
 
LVL 8

Accepted Solution

by:
Answers2000 earned 300 total points
ID: 1323060
Try this instead

AfxPostQuitMessage(0) ;

this will free any OLE libraries, then post a WM_QUIT message.

WM_QUIT will cause the MFC message loop to stop looping and thus terminate the app.

Be aware this is an undocumented MFC function (at least it is not in my versions of the docs), so may change in future MFC versions.  However given the number of calls to it peppered over MFC sources, you are probably pretty safe to call this.

0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

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

Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
In this post we will learn different types of Android Layout and some basics of an Android App.
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.
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
Suggested Courses

840 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