Solved

Alternate to PostQuitMessage

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
C Language combined operators 28 106
FMX StringGrid1->Canvas->FillRect Problem 3 127
operator overload: incompatible type and too many params 5 62
Safe conversion? 4 58
Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
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.

920 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

12 Experts available now in Live!

Get 1:1 Help Now