I have a HMENU and I know that the item lies at given position, having that information is it possible to do something like this: RunMenuItem(hMenu,3) where 3 is the position of that item ?
I have a HMENU and I know that the item lies at given position,
Share
When you select an item from a menu, one of two things can happen:
WM_COMMANDmessage is posted to the menu’s parent window, containing the menu item ID, orTrackPopupMenuwith theTPM_RETURNCMDflag, the selected item ID is returned as the result of the call toTrackPopupMenu.In the first case, you can simulate this programmatically by simply posting the
WM_COMMANDmessage yourself with the appropriate parameters. You would need to query theHMENUfor the menu item ID (usingGetMenuItemInfo).In the second case, there’s no easy way to simulate this, as it relies on the calling thread actually calling
TrackPopupMenuand processing the result.