function | Parameters | Return Values |
---|---|---|
PeekMessage | LPMSG lpMsg, pointer to structure for message HWND hWnd handle to window UINT wMsgFilterMin first message UINT wMsgFilterMax last message UINT wRemoveMsg removal flags |
BOOL |
Remarks
If a message is available, the return value is nonzero.
If no messages are available, the return value is zero.
function | Parameters | Return Values |
---|---|---|
GetMessage | LPMSG lpMsg address of structure with message HWND hWnd handle of window UINT wMsgFilterMin first message UINT wMsgFilterMax last message |
BOOL |
Remarks
If the function retrieves a message other than WM_QUIT, the return value is nonzero.
If the function retrieves the WM_QUIT message, the return value is zero.
If there is an error, the return value is -1. For example, the function fails if hWnd is an invalid window handle or lpMsg is an invalid pointer. To get extended error information, callGetLastError.
Example
PeekMessage
while (!bQuit)
{
if (PeekMessage (&msg, NULL, 0, 0, PM_REMOVE))
{
if (msg.message == WM_QUIT)
{
bQuit = TRUE;
}
else
{
TranslateMessage (&msg);
DispatchMessage (&msg);
}
}
GetMessage
while (GetMessage(&msg, NULL, 0, 0))
{
if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}