Solved

Alternate to PostQuitMessage

Posted on 2004-09-13
6
378 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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

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…
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
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.

705 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

18 Experts available now in Live!

Get 1:1 Help Now