gpt4 book ai didi

Delphi:弹出菜单

转载 作者:行者123 更新时间:2023-12-02 05:32:14 28 4
gpt4 key购买 nike

有一个 ListView +一个弹出菜单。我需要在存在项目时显示弹出菜单。菜单项数为 0 时不得出现。

这个大概的代码合适吗(可以作为基础)?

procedure TForm1.StringGrid1MouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
var P: TPoint;
begin
P:=GetClientOrigin;
if Button = mbRight then
PopupMenu1.Popup(X+P.X+StringGrid1.Left, Y+P.Y+StringGrid1.Top);
end;

还有其他方法吗?

谢谢!!!

最佳答案

首先,不要对鼠标事件执行任何操作,因为可以从键盘调用弹出菜单。

在我看来,最好的方法是处理 OnPopup 事件。如果您希望菜单不显示,请调用Abort

procedure TForm1.PopupMenu1Popup(Sender: TObject);
begin
if SomeCondition then
Abort;
end;

关于Delphi:弹出菜单,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6879244/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com