views:

137

answers:

3

I want to display info when my mouse cursor is on an item in my menu by using SendMessage() to my statusbar. How do i get the current menu item ID ? I suppose they use same ID's as my Visual Studio shows in the menu editor.

I found these on msdn but none of them seems to serve my needs:

WM_COMMAND
WM_CONTEXTMENU
WM_ENTERMENULOOP
WM_EXITMENULOOP
WM_GETTITLEBARINFOEX
WM_MENUCOMMAND
WM_MENUDRAG
WM_MENUGETOBJECT
WM_MENURBUTTONUP
WM_NEXTMENU
WM_UNINITMENUPOPUP
A: 

Have you tried using..

GetFocus();

I think that returns a pointer to the control if I remember correctly.

gmcalab
A: 

While the user is moving around the menu you get WM_MENUSELECT messages. LOWORD(lParam) will be the id of the menu item unless what is currently being selected is a popup rather than an item.

so your code looks something like this

case WM_MENUSELECT
   {
   HMENU hmenu  = (HMENU) lParam;
   UINT  idItem = (UINT) LOWORD(wParam);
   UINT  flags  = (UINT) HIWORD(wParam);

   if (flags & MF_POPUP)
      {
      // idItem is actually a popup index
      HMENU hSubMenu = GetSubMenu(hmenu, idItem);
      idItem = 0; // assign an id to the menu, or just set to 0 for no output
      }

   // show menu info on status bar for idItem
   SendMessage(hwndStatbar, ..., idItem, ...);
   }
John Knoeller
interesting, but i cant seem to get it work... seems like the ID's are not the same as in the menu editor...
Newbie
I tried setting statusbar info with the lParam number, but it doesnt seem to change at all when i move cursor over different items... only when i open new submenu it changes... however, the wParam value seems to change when i move cursor over different item o.O
Newbie
sorry, that was a typo, should have been wParam, code is fixed now.
John Knoeller
ah great, its working now :) thanks
Newbie
A: 

(maybe not a complete answer, but) Can't you use use strings in the STRINGTABLE section of the resources ?

for example, for your menu ID:

MENUITEM "Your Menu Item...",              IDM_YOUR_MENU_ITEM

in the STRINGTABLE

STRINGTABLE 
BEGIN
    IDM_ALL_SURFACE_PROFILE_FEATURES "Message1\nMessage2"
 END

If memory serves me well, the first part of the string will be the text displayed in the statusbar.

Max.

Max
I set the strings now in there, but what code i need to send those in my statusbar? its not working by default...
Newbie
holy shit, my VS 2008 crashes every time i go to string table page :/
Newbie