Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

terminating application

Posted on 1998-10-07
2
Medium Priority
?
191 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
[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
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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
Ready to get certified? Check out some courses that help you prepare for third-party exams.
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.
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …

609 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