Last active
May 28, 2016 06:09
-
-
Save Fahrni/4ce26f04e831513b830574da00ce6ef2 to your computer and use it in GitHub Desktop.
ACL Library Message Dispatch Mechanism
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
LRESULT ACLWinBase::DispatchMessage | |
( | |
IN UINT uMsg, | |
IN WPARAM wParam, | |
IN LPARAM lParam | |
) | |
{ | |
LRESULT lResult(1); | |
UINT uSubMsg(WM_NULL); // By default this really isn't looked at. | |
// If we've received a W_COMMAND message or a | |
// W_NOTIFY message the dive into the sub-messages | |
// contained in these messages. | |
// | |
switch (uMsg) | |
{ | |
case WM_COMMAND: | |
{ | |
uSubMsg = LOWORD(wParam); | |
break; | |
} | |
case WM_NOTIFY: | |
{ | |
LPNMHDR pHDR = (LPNMHDR)lParam; | |
if (pHDR) | |
{ | |
// This is the REAL message. | |
// | |
uSubMsg = pHDR->code; | |
} | |
break; | |
} | |
case WM_SYSCOMMAND: | |
{ | |
uSubMsg = (UINT)wParam; | |
break; | |
} | |
} // Pre-message processing. | |
bool bail(false); | |
PWINMSGHNDLR pHandler = NULL; | |
// Check the Message map for the object, if the message passed | |
// in here matches one in the map then grab the name of the | |
// dispatch function and dispatch it! | |
// | |
for (ACLWinMessageMapCollection::iterator it = _msgMap.begin(); | |
it != _msgMap.end() && false == bail; | |
++it) | |
{ | |
// If the main command(wMsg) and the control ID(uSubMsg) | |
// match then we've found a command handler for the | |
// message. | |
// | |
if ((uMsg == (*it).uMsg) && | |
(uSubMsg == (*it).uSubMsg)) | |
{ | |
pHandler = (*it).pMsgHandler; | |
bail = true; | |
} | |
} | |
// If we found a matching message handler, then | |
// dispatch it otherwise return false. | |
// | |
if (pHandler) | |
{ | |
lResult = (this->*pHandler)(wParam, lParam); | |
} | |
return lResult; | |
} // ::DispatchMessage |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment