Discussion:
TrackPopupMenu WM_MOUSEMOVE
(too old to reply)
Sue
2011-04-21 01:19:30 UTC
Permalink
Raw Message
Hi,

I subclass the IE rebar window. And I call TrackPopupMenu to display
menu on my toolbar when user click button on my toolbar. Here is the
problem. After the TrackPopupMenu is called, it seems the subclass
window didn't receive a bunch of WM_MOUSEMOVE which it suppose to. If
the user doesn't try to display the menu and TrackPopupMenu is not
called, evething is fine. Looks like TrackPopupMenu is blocking
WM_MOUSEMOVE. How do I fix this? Thanks.
Dee Earley
2011-04-21 08:17:43 UTC
Permalink
Raw Message
Post by Sue
I subclass the IE rebar window. And I call TrackPopupMenu to display
menu on my toolbar when user click button on my toolbar. Here is the
problem. After the TrackPopupMenu is called, it seems the subclass
window didn't receive a bunch of WM_MOUSEMOVE which it suppose to. If
the user doesn't try to display the menu and TrackPopupMenu is not
called, evething is fine. Looks like TrackPopupMenu is blocking
WM_MOUSEMOVE. How do I fix this? Thanks.
Menus capture the mouse for them to work properly.
This means that nothing else gets mouse events until it is dismissed by
clicking an option, or outside (this is why it needs to capture the mouse)
--
Dee Earley (***@icode.co.uk)
i-Catcher Development Team
http://www.icode.co.uk/icatcher/

iCode Systems

(Replies direct to my email address will be ignored.
Please reply to the group.)
j***@gmail.com
2014-06-07 09:33:40 UTC
Permalink
Raw Message
Post by Sue
Hi,
I subclass the IE rebar window. And I call TrackPopupMenu to display
menu on my toolbar when user click button on my toolbar. Here is the
problem. After the TrackPopupMenu is called, it seems the subclass
window didn't receive a bunch of WM_MOUSEMOVE which it suppose to. If
the user doesn't try to display the menu and TrackPopupMenu is not
called, evething is fine. Looks like TrackPopupMenu is blocking
WM_MOUSEMOVE. How do I fix this? Thanks.
Use windows hook, sample code:
g_menuMsgHook = SetWindowsHookEx(WH_MOUSE, sMenuMouseProc, 0, GetCurrentThreadId());
g_currMenuButton = this;
int menuId = menu_.trackMenu(TPM_LEFTALIGN | TPM_LEFTBUTTON,
trackPt.x, trackPt.y, hwnd());
g_currMenuButton = nullptr;
UnhookWindowsHookEx(g_menuMsgHook); //this is a must need

LRESULT CALLBACK MenuButton::sMenuMouseProc(_In_ int nCode, _In_ WPARAM wParam, _In_ LPARAM lParam)
{
WCHAR className[MAX_PATH] = { 0 };
WCHAR caption[MAX_PATH] = { 0 };
WCHAR message[MAX_PATH] = { 0 };
if (nCode < 0) {
return CallNextHookEx(g_menuMsgHook, nCode, wParam, lParam);
}
if (nCode == HC_ACTION) {
if (wParam == WM_MOUSEMOVE) {
PMOUSEHOOKSTRUCT hs = (PMOUSEHOOKSTRUCT)(lParam);
}
return 0;
}
else {
return CallNextHookEx(g_menuMsgHook, nCode, wParam, lParam);
}
}

Loading...