Solved

terminating application

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

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…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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 you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

747 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