Announcement

Collapse
No announcement yet.

Find Menu from its caption

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Michael Mattias
    replied
    Get handle to menu with GetMenu(hWnd)
    Use GetMenuItemCount() against menu handle.
    For each item, use GetMenuItemInfo() to get text or handle to popup menu item
    If item is a submenu, use GetMenuItemCount + GetMenuItemInfo against those items

    Yes, it is recursive.

    If you don't have an Hwnd, I suppose you could EnumWindows() for all top-level windows, and check 'em all.
    Last edited by Michael Mattias; 12 Jun 2008, 08:14 AM. Reason: Fixed typo and added GetMenuItemCount() to step for submenu

    Leave a comment:


  • Cliff Nichols
    started a topic Find Menu from its caption

    Find Menu from its caption

    I am trying to do something that may be a lil "Bass-Ackwards" but I think may be able to be done. Unfortunately the only clues I have involve the mouse being over the menu.

    What I would like to do is
    • Given I know the text displayed in a menu (either from file or me just knowing the caption)
    • Walk the menu bar until I find a caption that matches
    • Get the position the menu item is in
    • Get the ID of that menu item


    I know each can be gotten separately, but for the life of me, I can not find a way of doing the reverse, when all you have is the caption to go by (at least not without, moving the mouse to that menuitem)

    Am I just missing something? or Mis-Reading the Docs? or can it even be done?????
Working...
X