to cobi(我是小新) 你知道吗?因为在鼠标点击在窗口中弹出菜单与鼠标有一定的距离,我想那是x,y 座标没有进行单位换算,不知是不是?
to heifei() 对,正如你所说的,鼠标和弹出菜单的左上角不对齐?
delphi中好像没有vb中的scale功能,只能自己进行控制了
要对齐左上角把PopupMenu的alignment的属性设为PlLeft就行了
to heifei() popupmenu的alignment的属性设为plleft也不行,是不是像iBear(大熊) 所说只能自己控制 我在x ,y上各自加上一定的数就可以,但没规律可寻.请教!
你可以拦截鼠标右键消息: type TForm1 = class(TForm) PopupMenu1: TPopupMenu; sdfdf1: TMenuItem; protected procedure WndProc(var Message: TMessage); override; end; var Form1: TForm1; implementation {$R *.dfm} procedure TForm1.WndProc(var Message: TMessage); var MPos: TPoint; begin MPos:= Mouse.CursorPos;//Position of mouse event with Message do case Msg of WM_RBUTTONDOWN: begin PopupMenu1.Popup(MPos.X+20, MPos.Y+10);//You can adjust the Popupmenu end; //position here end; inherited; end;end.
你知道吗?因为在鼠标点击在窗口中弹出菜单与鼠标有一定的距离,我想那是x,y 座标没有进行单位换算,不知是不是?
对,正如你所说的,鼠标和弹出菜单的左上角不对齐?
popupmenu的alignment的属性设为plleft也不行,是不是像iBear(大熊) 所说只能自己控制
我在x ,y上各自加上一定的数就可以,但没规律可寻.请教!
type
TForm1 = class(TForm)
PopupMenu1: TPopupMenu;
sdfdf1: TMenuItem;
protected
procedure WndProc(var Message: TMessage); override;
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.WndProc(var Message: TMessage);
var
MPos: TPoint;
begin
MPos:= Mouse.CursorPos;//Position of mouse event
with Message do
case Msg of
WM_RBUTTONDOWN:
begin
PopupMenu1.Popup(MPos.X+20, MPos.Y+10);//You can adjust the Popupmenu
end; //position here
end;
inherited;
end;end.