Solved

terminating application

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Decoding 32 bit binary streams 6 54
Unix / Linux grid computing 5 169
VBA "SendKeys" Syntax for Multiple Keystrokes 7 126
Can not remove SSL certificate on iPhone 6 - iOS10.2 12 1,334
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…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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.
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

726 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