In general, the message processing is as follows, TranslateMessage transforms Virtual-keys message to characters message, DispatchMessage dispatches a message to the window program.
// GetMessage The second argument is an HWND, which is set to NULL, // if set to Hwnd,wm_destroy message will not respond to while (GetMessage (&msg,null,0,0) { translatemessage (&msg); Diapatchmessage (&msg); }
If the window contains a non-modal dialog box, you need to use IsDialogMessage to determine whether the message is for a particular dialog box and handle it.
while (GetMessage (&msg,null,0,0) { if(hdlgmodeless==0| | IsDialogMessage (hdlgmodeless,&msg) { translatemessage (&msg); Diapatchmessage (&msg); }
}
If you are working with shortcut keys, you also need to process the shortcut key messages in advance through TranslateAccelerator.
while 0 0 ) ) { if0 | |! IsDialogMessage (hdlgmodeless, &msg)) { if (! TranslateAccelerator (hwnd, Haccel, &msg)) { translatemessage (&msg); DispatchMessage (&msg); }}}
Win32 message (MSG) processing