PostQuitMessage function
Applies to: desktop apps only
Indicates to the system that a thread has made a request to terminate (quit). It is typically used in response to a WM_DESTROY message.
Syntax
VOID WINAPI PostQuitMessage( __in int nExitCode );
Parameters
- nExitCode [in]
-
Type: int
The application exit code. This value is used as the wParam parameter of the WM_QUIT message.
Return value
This function does not return a value.
Remarks
The PostQuitMessage function posts a WM_QUIT message to the thread's message queue and returns immediately; the function simply indicates to the system that the thread is requesting to quit at some time in the future.
When the thread retrieves the WM_QUIT message from its message queue, it should exit its message loop and return control to the system. The exit value returned to the system must be the wParam parameter of the WM_QUIT message.
Examples
For an example, see Posting a Message.
Requirements
|
Minimum supported client | Windows 2000 Professional |
|---|---|
|
Minimum supported server | Windows 2000 Server |
|
Header |
|
|
Library |
|
|
DLL |
|
See also
- Reference
- GetMessage
- PeekMessage
- PostMessage
- WM_DESTROY
- WM_QUIT
- Conceptual
- Messages and Message Queues
Send comments about this topic to Microsoft
Build date: 2/3/2012
- 1/17/2012
- ArnoudMulder
- 1/17/2012
- ArnoudMulder
- 12/5/2011
- chksr
MSG msgs = { };
int catcherror;
while((catcherror = GetMessageW(&msgs, swhandle, 0, 0)) != 0)
{
if(catcherror == -1)
return msgs.message;
TranslateMessage(&msgs);
DispatchMessage(&msgs);
} // Take a look at the exit value output at the end of execution.
You can avoid the stall by assigning a null value to the variable storing the destroyed windows handle:
LRESULT CALLBACK WinProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam)
{
switch(message)
{
case(WM_DESTROY):
hwnd = NULL;
PostQuitMessage(0);
...
GetMessage will then pick up any messages in the thread. :-)
- 8/25/2010
- EVHClarity