用getcursorpos时菜单在鼠标点击处弹出
procedure TForm1.Button1Click(Sender: TObject);
var
p:TPoint;
begin
getcursorpos(p);
PopupMenu1.popup(p.x,p.y);
end;
还有一种方法效果更好:
procedure TForm1.Button1Click(Sender: TObject);
var
p:TPoint;
begin
p:=clienttoscreen(point(Button1.left,Button1.top+Button1.Height));
PopupMenu1.popup(p.X,p.Y);
end;
tmd,其实只要用
var
p:TPoint;
begin
p:=TBitBtn(sender).Parent.clienttoscreen(point(TBitBtn(sender).left,TBitBtn(sender).top+TBitBtn(sender).Height));
PopupMenu1.popup(p.X,p.Y);
end;