Solved

Alternate to PostQuitMessage

Posted on 2004-09-13
6
391 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
[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
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: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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

Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
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 goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

752 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