The previous section describes how to obtain a message from the system queue, check the function of the shortcut key, and convert the character message function. The last thing to do is to call the dispatchmessage function, it means to send this message to windowproc, the message processing function in the window.
The dispatchmessage function is declared as follows:
Winuserapi
Lresult
Winapi
Dispatchmessagea (
_ In const MSG * lpmsg );
Winuserapi
Lresult
Winapi
Dispatchmessagew (
_ In const MSG * lpmsg );
# Ifdef Unicode
# Define dispatchmessage dispatchmessagew
# Else
# Define dispatchmessage dispatchmessagea
# Endif //! Unicode
Lpmsg refers to the message to be sent to the message processing function windowproc.
An example of calling this function is as follows:
#001 // master Program Portal
#002 //
#003 // Cai junsheng 2007/07/19
#004 // QQ: 9073204.
#005 //
#006 int apientry _ twinmain (hinstance,
#007 hinstance hprevinstance,
#008 lptstr lpcmdline,
#009 int ncmdshow)
#010 {
#011 unreferenced_parameter (hprevinstance );
#012 unreferenced_parameter (lpcmdline );
#013
#014 //
#015 MSG;
#016 haccel hacceltable;
#017
#018 // load the global string.
#019 loadstring (hinstance, ids_app_title, sztitle, max_loadstring );
#020 loadstring (hinstance, idc_testwin, szwindowclass, max_loadstring );
#021 myregisterclass (hinstance );
#022
#023 // application initialization:
#024 if (! Initinstance (hinstance, ncmdshow ))
#025 {
#026 return false;
#027}
#028
#029 hacceltable = loadaccelerators (hinstance, makeintresource (idc_testwin ));
#030
#031 // message loop:
#032 bool Bret;
#033 while (Bret = getmessage (& MSG, null, 0, 0 ))! = 0)
#034 {
#035 if (Bret =-1)
#036 {
#037 // handling error.
#038
#039}
#040 else if (! Translateaccelerator (msg. hwnd, hacceltable, & MSG ))
#041 {
#042 translatemessage (& MSG );
#043 dispatchmessage (& MSG );
#044}
#045}
#046
#047 return (INT) msg. wparam;
#048}
#049
Row 3 calls the dispatchmessage function to send messages.
This article from the csdn blog, reproduced please indicate the source: http://blog.csdn.net/caimouse/archive/2007/07/24/1704627.aspx