开发者

How to get the currently focused menu item ID?

开发者 https://www.devze.com 2022-12-21 03:59 出处:网络
I want to display info when my mouse cursor is on an ite开发者_StackOverflowm 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 a

I want to display info when my mouse cursor is on an ite开发者_StackOverflowm 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


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, ...);
   }


Have you tried using..

GetFocus();

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


(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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号