Solved

terminating application

Posted on 1998-10-07
2
181 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 100 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
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.
As a trusted technology advisor to your customers you are likely getting the daily question of, ‘should I put this in the cloud?’ As customer demands for cloud services increases, companies will see a shift from traditional buying patterns to new…

920 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now