Hook procedure for WH_GETMESSAGE hook type. This function is more or less a combination of MSDN KB articles Q187988 and Q216503. See MSDN for additional details
| 33 | // This function is more or less a combination of MSDN KB articles |
| 34 | // Q187988 and Q216503. See MSDN for additional details |
| 35 | LRESULT CALLBACK CDialogMessageHook::GetMessageProc(int nCode, |
| 36 | WPARAM wParam, LPARAM lParam) |
| 37 | { |
| 38 | // If this is a keystrokes message, pass it to IsDialogMessage for tab |
| 39 | // and accelerator processing |
| 40 | LPMSG lpMsg = (LPMSG) lParam; |
| 41 | |
| 42 | // check if there is a menu active |
| 43 | HWND hMenuWnd = NULL; |
| 44 | EnumWindows(MyEnumProc, (LPARAM)&hMenuWnd); |
| 45 | |
| 46 | if (hMenuWnd == NULL && |
| 47 | (nCode >= 0) && |
| 48 | PM_REMOVE == wParam && |
| 49 | (lpMsg->message >= WM_KEYFIRST && lpMsg->message <= WM_KEYLAST)) |
| 50 | { |
| 51 | HWND hWnd, hActiveWindow = GetActiveWindow(); |
| 52 | THWNDCollection::iterator it = m_aWindows.begin(); |
| 53 | |
| 54 | // check each window we manage to see if the message is meant for them |
| 55 | while (it != m_aWindows.end()) |
| 56 | { |
| 57 | hWnd = *it; |
| 58 | |
| 59 | if (::IsWindow(hWnd) && |
| 60 | ::IsDialogMessage(hWnd, lpMsg)) |
| 61 | { |
| 62 | // The value returned from this hookproc is ignored, and it cannot |
| 63 | // be used to tell Windows the message has been handled. To avoid |
| 64 | // further processing, convert the message to WM_NULL before |
| 65 | // returning. |
| 66 | lpMsg->hwnd = NULL; |
| 67 | lpMsg->message = WM_NULL; |
| 68 | lpMsg->lParam = 0L; |
| 69 | lpMsg->wParam = 0; |
| 70 | |
| 71 | break; |
| 72 | } |
| 73 | |
| 74 | it++; |
| 75 | } |
| 76 | } |
| 77 | |
| 78 | // Passes the hook information to the next hook procedure in |
| 79 | // the current hook chain. |
| 80 | return ::CallNextHookEx(m_hHook, nCode, wParam, lParam); |
| 81 | } |
| 82 | |
| 83 | extern CAppModule _Module; |
| 84 |
nothing calls this directly
no outgoing calls
no test coverage detected