【发布时间】:2011-04-28 13:41:43
【问题描述】:
我想在点击一个按钮时显示一个弹出菜单,但是这个程序在 Delphi XE 中有错误。
procedure ShowPopupMenuEx(var mb1:TMouseButton;var X:integer;var Y:integer;var pPopUP:TPopupMenu);
var
popupPoint : TPoint;
begin
if (mb1 = mbLeft) then begin
popupPoint.X := x ;
popupPoint.Y := y ;
popupPoint := ClientToScreen(popupPoint); //Error Here
pPopUP.Popup(popupPoint.X, popupPoint.Y) ;
end;
end;
procedure TForm1.Button1MouseUp(Sender: TObject; Button: TMouseButton;Shift: TShiftState; X, Y: Integer);
begin
ShowPopupMenuEx(button,Button1.Left,Button1.Top,PopupMenu1); //Error Here
end;
单击按钮时显示此错误:
[DCC 错误] Form1.pas(205): E2010 不兼容的类型:'HWND' 和 'TPoint'
[DCC 错误] Form1.pas(398): E2197 常量对象不能作为 var 参数传递
[DCC 错误] Form1.pas(398): E2197 常量对象不能作为 var 参数传递
有没有更好的方法来显示弹出菜单,当点击一个按钮?
【问题讨论】:
-
为什么在 ShopPopupMenuEx( ) 过程中使用 var 参数?
-
哎呀,这是我的错误,对不起。
标签: delphi button cursor-position popupmenu