在 Windows 中创建菜单按钮 [英] Creating a menu button in Windows

查看:19
本文介绍了在 Windows 中创建菜单按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Microsoft 的 用户体验交互指南提供了一些 UI 指南何时使用菜单按钮:

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

  • 如何在 Vista 及更高版本中创建拆分按钮
  • 如何创建带有下拉菜单的工具栏按钮
  • 如何创建常规按钮并手动连接弹出菜单的 OnClick 事件处理程序

但是有没有标准的方法来创建一个按钮,而不是在工具栏中,带有小三角形,在点击时自动弹出一个菜单?

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?

(我使用的是 Delphi/C++Builder,但欢迎使用其他解决方案.)

(I'm using Delphi / C++Builder, but other solutions are welcome.)

推荐答案

您可以使用 OnClick 来强制弹出,并且为了一致性不要使用光标位置,而是使用控件位置.

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;

然后,您可以使用 Delphi 2010 按钮或以前版本的 TBitBtn 添加字形",并将位图/字形属性分配给适当的图像并右对齐.

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.

这篇关于在 Windows 中创建菜单按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆