如何在enable=false的控件上弹出右键菜单(36)

  • 主题发起人 主题发起人 machcat
  • 开始时间 开始时间
M

machcat

Unregistered / Unconfirmed
GUEST, unregistred user!
前提是控件的enable=false,弹出右键菜单
 
var P: TPoint;begin Button1.Enabled:= false; //Button1.Enabled为false,在Button1上弹出菜单 P.X:= Button1.Left + (Button1.Width div 2); P.Y:= Button1.Top + (Button1.Height div 2); P:= Button1.Parent.ClientToScreen(P); PopupMenu1.Popup(P.X, P.Y);end;
 
谢谢回复,控件是dbgrid,并且Align=alClient,enable=false,在鼠标点击处弹出右键菜单,具体该怎么做
 
获得鼠标点击处的坐标,然后弹出菜单
 
procedure TForm1.FormMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);var p :TPoint;begin GetCursorPos(p); ScreenToClient(p); if Button in [mbRight] then begin //p.X := X; //p.Y := Y; if (X >= DBGrid1.Left) and (X <= DBGrid1.Left+DBGrid1.Width) and (Y >= DBGrid1.Top) and (Y <= DBGrid1.Height + DBGrid1.Top) then begin PopupMenu1.Popup(p.X,p.Y); end; end;end;
 
谢谢各位
 
后退
顶部