Retrieves messages from the calling thread's message queue.
hWnd is NULL.hWnd is NULL.If the function succeeds, the return value is non-zero. If the function retrieves a quit message (when wMsgFilterMin and wMsgFilterMax are both zero), the return value is zero. If there is an error, the return value is -1.
The GetMessageW function retrieves a message from the message queue of the calling thread and places the message in the structure pointed to by the lpMsg parameter.
hWnd is NULL, GetMessageW retrieves messages for any window that belongs to the calling thread.wMsgFilterMin and wMsgFilterMax are both zero, GetMessageW retrieves all messages.wMsgFilterMin and wMsgFilterMax specify a range of messages, GetMessageW retrieves only messages within that range.hWnd) to GetMessageW. If you are retrieving messages for any window belonging to the thread, pass NULL for hWnd.
MSG msg;
while (GetMessage(&msg, NULL, 0, 0) > 0) {
TranslateMessage(&msg);
DispatchMessage(&msg);
}