tags:

views:

110

answers:

1

Is there a way to determine if a menu is dropped down in the win32 api? Something that could be used like so:

HMENU hMenu = GetMenu(hWnd);

HMENU hSubMenu = GetSubMenu(hMenu);

// Is hSubMenu dropped down?

+1  A: 

I'm not sure of a way to operate specifically on HMENUs to see if the menu is showing (and a quick scan of the platform SDK docs didn't turn up anything specific), but you might be able to use the GetMenuItemInfo function to get a MENUITEMINFO struct relating to the menu item which owns the dropdown. If the fState member has MFS_HILITE set, that should indicate that the item is selected and the sub menu is most likely open. Correctness isn't guaranteed on my part but it's worth experimenting with.

Another possible option would be using FindWindow with the class "#32768" to find the hWnd of whatever menus may be open, and sending the MN_GETHMENU message to whichever windows you find to retrieve the HMENU and compare it to the expected value from GetSubMenu.

Volte