1

在我的应用程序(Delphi Xe2)中,我有“多选”按钮(即“导出”按钮有“导出到 PDF”和“导出到 XLS”选项)。我需要一个菜单​​,就像我将鼠标移到按钮(或面板或其他对象)上时出现的弹出菜单一样。此菜单需要出现在按钮下方,并且需要是“VCL Stylable”组件。我尝试了一个 TPopUpMenu 但隐藏起来不方便。我也可以考虑使用 OnClick 事件而不是 OnEnter 来显示菜单。

4

1 回答 1

4

您可以将 aTButton的样式设置为bsSplitButton,与TPopupActionBar设置为按钮DropDownMenu属性的 a 一起使用。当您单击具有向下箭头的右侧拆分时,菜单会下拉。仅适用于 Vista 及更高版本..

对于较早的操作系统,可以使用以下内容:

procedure TForm1.Button1Click(Sender: TObject);
var
  Pt: TPoint;
begin
  Pt := ClientToScreen(Point((Sender as TButton).Left, (Sender as TButton).Top));
  PopupActionBar1.Popup(Pt.X, Pt.Y + (Sender as TButton).Height);
end;
于 2012-05-11T16:48:04.973 回答