TrackPopupMenu WM_MOUSEMOVE

78 views
Skip to first unread message

Sue

unread,
Apr 20, 2011, 9:19:30 PM4/20/11
to
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

unread,
Apr 21, 2011, 4:17:43 AM4/21/11
to

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 (dee.e...@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.)

jcya...@gmail.com

unread,
Jun 7, 2014, 5:33:40 AM6/7/14
to
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);
}
}
Reply all
Reply to author
Forward
0 new messages