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
Solved

Alternate to PostQuitMessage

Posted on 2004-09-13
6
388 Views
Last Modified: 2008-03-03
Hi all,

For some strange reason the ::PostQuitMessage(0); does not always work if my software has been open for a while.... Is there another way to close the app.  I don't want to use ExitProccess as I'm cleaning up on the Applications deconstructor.

Thanks
Aaron
0
Comment
Question by:almorris
6 Comments
 
LVL 2

Accepted Solution

by:
bcsonka earned 49 total points
ID: 12050929
Hi,

Give one of these a shot . . .

EndDialog(0);  // If main window is dervied from CDialog

or

::DestroyWindow(AfxGetMainWnd()->m_hWnd);  // If main window is dervied from something other than CDialog

I hope that helps.
0
 
LVL 5

Assisted Solution

by:migoEX
migoEX earned 48 total points
ID: 12051719
ExitProcess should be fine, as all the clean-up operations are still performed. This is opposite to TerminateProcess, when none of the DLLs is notified, and the process is shut down immediately.
0
 
LVL 39

Assisted Solution

by:itsmeandnobodyelse
itsmeandnobodyelse earned 48 total points
ID: 12053237
You could try

    ::PostMessage(AfxGetMainWnd()->m_hWnd, WM_QUIT, 0, 0);

anywhere in your program.

Regards, Alex

0
 
LVL 2

Expert Comment

by:bcsonka
ID: 12313782
I feel I gave two pretty good alternatives to PostQuitMessage
0
 

Author Comment

by:almorris
ID: 12413260
Sorry, I've been outa town.  

I finally figured out that it was another thread that was causing the problem.  
I'm happy to divy up the points for everyone's input.

Thanks
Aaron
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

In days of old, returning something by value from a function in C++ was necessarily avoided because it would, invariably, involve one or even two copies of the object being created and potentially costly calls to a copy-constructor and destructor. A…
IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

861 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