This is an old revision of the document!
Table of Contents
This is part of Win16 API which allow to create versions of program from one source code to run under OS/2 and Win16. Under OS/2 program can be running under Win-OS/2 if program is Windows NE executable, and with help on Windows Libraries for OS/2, if it is OS/2 NE executable. Here is a WLO to OS/2 API mapping draft
PostQuitMessage
Brief
The PostQuitMessage function posts a message to Windows indicating that an application is requesting to terminate execution (quit). This function is typically used in response to a `WM_DESTROY` message.
Syntax
VOID WINAPI PostQuitMessage(int nExitCode);
Parameters
- nExitCode — Specifies an application-defined exit code. It must be the wParam parameter of the `WM_QUIT` message.
Return Code
This function does not return a value.
Notes
- The PostQuitMessage function posts a `WM_QUIT` message to the application and returns immediately; the function simply indicates to the system that the application will request to quit some time in the future.
- When the application receives the `WM_QUIT` message, it should exit the message loop in the main function and return control to Windows.
Example Code
C Binding
#include <windows.h> LRESULT CALLBACK __export WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { switch (msg) { case WM_DESTROY: PostQuitMessage(0); return 0; } return DefWindowProc(hwnd, msg, wParam, lParam); } int WINAPI WinMain(HANDLE hInstance, HANDLE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { MSG msg; /* ... window class registration and creation ... */ while (GetMessage(&msg, NULL, 0, 0)) { TranslateMessage(&msg); DispatchMessage(&msg); } return (int)msg.wParam; }
MASM Binding
EXTRN PostQuitMessage:FAR WndProc PROC FAR cmp ax, WM_DESTROY je handle_destroy ; ... other messages ... handle_destroy: push 0 ; nExitCode = 0 call PostQuitMessage xor ax, ax ; return 0 (message handled) retf WndProc ENDP ; Message loop that catches WM_QUIT WinMain PROC FAR ; ... initialization ... message_loop: lea ax, msg push ax ; lpMsg push 0 ; hWnd push 0 ; wMsgFilterMin push 0 ; wMsgFilterMax call GetMessage cmp ax, 0 je exit_app ; FALSE — WM_QUIT received lea ax, msg push ax call TranslateMessage lea ax, msg push ax call DispatchMessage jmp message_loop exit_app: mov ax, msg.wParam ; return exit code from WM_QUIT retf WinMain ENDP




