有一个列表视图+一个PopUpMenu。我需要的是,当项目出现时出现PopUpMenu。当项目为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;还有别的办法吗?
谢谢!
发布于 2011-07-30 05:36:49
首先,不要在鼠标事件上做任何事情,因为弹出菜单可以从键盘调用。
在我看来,最好的方法是处理OnPopup事件。如果您不希望菜单出现,请调用Abort。
procedure TForm1.PopupMenu1Popup(Sender: TObject);
begin
if SomeCondition then
Abort;
end;https://stackoverflow.com/questions/6879244
复制相似问题