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

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

问题描述

微软用户体验交互准则给出何时使用菜单中的某些UI指南键:

Microsoft's User Experience Interaction Guidelines give some UI guidelines for when to use a menu button:

如何做我创建这些菜单按钮中的一个?我发现的信息

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;

您可以再添加字形使用一个德尔福2010按钮,或previous版本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天全站免登陆