+LRESULT CMenuFocusManager::MsgFilterHook(INT nCode, WPARAM wParam, LPARAM lParam)
+{
+ HWND parent;
+ HWND child;
+ POINT pt;
+ int iHitTestResult;
+
+ if (nCode < 0)
+ return CallNextHookEx(m_hMsgFilterHook, nCode, wParam, lParam);
+
+ if (nCode == MSGF_MENU)
+ {
+ BOOL callNext = TRUE;
+ MSG* msg = reinterpret_cast<MSG*>(lParam);
+
+ // Do whatever is necessary here
+
+ switch (msg->message)
+ {
+ case WM_MOUSEMOVE:
+
+ pt = msg->pt;
+
+ parent = WindowFromPoint(pt);
+
+ ScreenToClient(parent, &pt);
+
+ child = ChildWindowFromPoint(parent, pt);
+
+ if (child != m_parentToolbar)
+ break;
+
+ ScreenToClient(m_parentToolbar, &msg->pt);
+
+ /* Don't do anything if the mouse has not been moved */
+ if (msg->pt.x == m_ptPrev.x && msg->pt.y == m_ptPrev.y)
+ return TRUE;
+
+ m_ptPrev = msg->pt;
+
+ iHitTestResult = SendMessageW(m_parentToolbar, TB_HITTEST, 0, (LPARAM) &msg->pt);
+
+ /* Make sure that iHitTestResult is one of the menu items and that it is not the current menu item */
+ if (iHitTestResult >= 0)
+ {
+ if (SendMessage(m_parentToolbar, WM_USER_ISTRACKEDITEM, iHitTestResult, 0))
+ {
+ SendMessage(m_currentFocus, WM_CANCELMODE, 0, 0);
+ PostMessage(m_parentToolbar, WM_USER_CHANGETRACKEDITEM, iHitTestResult, iHitTestResult);
+ return TRUE;
+ }
+ }
+ break;
+ }
+
+ if (!callNext)
+ return 0;
+ }
+
+ return CallNextHookEx(m_hMsgFilterHook, nCode, wParam, lParam);
+}
+