RSS订阅 | 匿名投稿
您的位置:网站首页 > 程序 > 正文

delphi 实现窗体随着鼠标移动

作者:admin 来源: 日期:2018/3/5 12:54:47 人气: 标签:

private  //窗体移动;
OldPos,NewPos:TPoint;
bMove:Boolean;
 
procedure TForm1.FormMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
bMove:=True;
OldPos:=ClientToScreen(Point(X,Y));
end;
 
procedure TForm1.FormMouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
begin
if not bMove then Exit;
NewPos:=ClientToScreen(Point(X,Y));
Left:=Left+NewPos.X-OldPos.X;
Top:=Top+NewPos.Y-OldPos.Y;
OldPos:=NewPos;
end;
 
procedure TForm1.FormMouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
bMove:=False;
end;  

读完这篇文章后,您心情如何?
0
0
0
0
0
0
0
0
本文网址:
下一篇:没有资料