Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

TrackPopupMenuEx and WM_MENUSELECT - Visual C++ Win32

310 views
Skip to first unread message

Ryan Hehn

unread,
Jan 11, 2001, 5:17:37 PM1/11/01
to
Hello,

I've created a system tray icon with an asscociated popup menu. Using
TrackPopupMenuEx, my program receives a WM_MENUSELECT when a user selects an
item on the menu:

LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM
Param)
{
case WM_RBUTTONDOWN::
{
...
TrackPopupMenuEx(menu, TPM_RIGHTBUTTON|TPM_BOTTOMALIGN, pt.x, pt.y,
hwnd, NULL);
...
}
case WM_MENUSELECT:
{
UINT item = (UINT) LOWORD(wParam);
UINT flags = (UINT) HIWORD(wParam);
HMENU hmenu = (HMENU) lParam;
...

I can determine that MF_MOUSESELECT has occurred using flags, but hmenu is
NULL and item is 0.

According to the documentation, a NULL hmenu indicates the system has closed
the menu.

Does anyone have any insight as to why I'm receiving a NULL menu? Is this a
timing issue related to the system closing the menu after choosing a menu
item?

Thanks,

Ryan Hehn

Igor Tandetnik

unread,
Jan 11, 2001, 5:24:48 PM1/11/01
to
Why do you need WM_MENUSELECT at all? Handle WM_COMMAND
--
With best wishes,
Igor Tandetnik

"Ryan Hehn" <rbh...@NOSPAMhydro.mb.ca> wrote in message
news:eugGFxBfAHA.1244@tkmsftngp03...

Daniel Allen

unread,
Jan 13, 2001, 11:49:38 PM1/13/01
to
Dear Ryan,

WM_MENUSELECT is where a cursor is over an menu item, not when the user
selects something. You should use the HANDLE_WM_COMMAND(...) command.

Ryan Hehn <rbh...@NOSPAMhydro.mb.ca> wrote in message
news:eugGFxBfAHA.1244@tkmsftngp03...

0 new messages