1
votes

Is it possible 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.

3
This is potentially very, very dangerous.Andreas Rejbrand
It's Larry Wall asking the question. Remember, there's more than one way to do it.David Heffernan
Yours would be the only program with that behavior. The behavior could only be discovered by accident, because anyone who's had some experiencer with menus knows this isn't how they work. Then you might expect bug reports from those who did discover it. It's almost never a good idea to alter such fundamental UI behaviors.Marek Jedliński
The answer that I've posted in this question covers similar grounds. Have a read at that one and then decide if it's worth the effort and using undocumented messages.Sertac Akyuz

3 Answers

4
votes

That is both not possible (with standard windows menus) and confusing the user (because user experience will contradict with your behavior).

2
votes

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

0
votes

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.