Is it possib开发者_StackOverflowle for a popupmenu to execute the first item in a submenu. On mouse over will display the submenu, If I click on popup can I execute the click on the first submenu item? This would be so user does not have to move to the submenu and select the first item. Though is that it will execute the most used option in this case the first item. Using Delphi 2009.
That is both not possible (with standard windows menus) and confusing the user (because user experience will contradict with your behavior).
Take a look at TMenuItem.Default. Double click on parent item will execute the default sub menu item. Perhaps not good enough for you but it does not break the expected behavior from a menu.
TMenuItem.Default
You could use these:
Windows.HiliteMenuItem(Handle, TMessage(Msg).WParam, 0, MF_BYPOSITION or MF_HILITE);
Windows.PostMessage(Handle, WM_KEYDOWN, VK_DOWN, 0);
then post another message to click the selected item.
精彩评论