开发者

Delphi Popup menu with submenu and click on item will execute the first item in the submenu, possible?

开发者 https://www.devze.com 2023-02-04 12:59 出处:网络
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

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.

0

精彩评论

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

关注公众号