Microsoft's User Experience Interaction Guidelines give some UI guidelines for when to use a menu button:
http://i.msdn.microsoft.com/Aa511453.command51(en-us,MSDN.10).png
How do I create one of these menu buttons? I've found information on
But is there any standard way to create a button, not in a toolbar, with the little down triangle, that automatically pops up a menu when clicked?
(I'm using Delphi / C++Builder, but other solutions are welcome.)
Head to Settings > Personalization > Start. On the right, scroll all the way to the bottom and click the “Choose which folders appear on Start” link. Choose whatever folders you want to appear on the Start menu. And here's a side-by-side look at how those new folders look as icons and in the expanded view.
To assign a menu to a window, use the SetMenu function or specify the menu's handle in the hMenu parameter of the CreateWindowEx function when creating a window.
I press the Alt key and hold it down for around one second. Upon release, the invisible menu bar appears. This trick works for most every kind of window.
You can use the OnClick to force the popup, and for consistency don't use the cursor position, but rather the control position.
procedure TForm1.Button1Click(Sender: TObject);
var
pt : TPoint;
begin
Pt.X := Button1.Left;
Pt.Y := Button1.Top+Button1.Height;
pt := ClientToScreen(Pt);
PopupMenu1.Popup(pt.x,pt.y);
end;
You can then add the "glyph" using either a Delphi 2010 button, or a previous version TBitBtn and assign the bitmap/glyph property to an appropriate image and align right.
You don't mention which version of Delphi you are using, but in Delphi 2010 TButton has new properties for this: DropDownList which can be associated with a TPopupMenu to define the menu items, and Style which can be set to bsSplitButton.
This produces a button that you can press that also has a dropdown arrow on the right of it, To make the menu popup when you click to the left of the arrow this code in the button click handler should do the job.
procedure TForm1.Button1Click(Sender: TObject);
var
CursorPos: TPoint;
begin
GetCursorPos(CursorPos);
PopupMenu1.Popup(CursorPos.X, CursorPos.Y);
end;
in previous versions of Delphi I think you had to use TToolBar.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With