我在mousedown里做的记录起始点,在mousemove里做了控件的移动,所以在mousedown里记录下的点就是mouseup的点,不能记录下mousedown的点,请问各位有没有全局变量,可以在mousedown里记录下mouse移动的起始点的位置?先谢了
解决方案 »
- 控制excel文件,出现------OLE error 800A03EC-----错误
- 初学者
- 请教使用HOOK截获串口数据
- 在DLL中使用ADO数据库的问题,100分!
- 打開窗體時有下列錯誤顯示
- 找图标
- idsmtp发送邮件时如何显示进度
- WinSockAPI的问题
- *******************RX Library如何安装????急!急!急!急!急!急!急!急!********
- 安卓下,锁屏继续运行问题
- ado连oracle,查a表的b列,正的显示在一列,负的显示在另一列,怎么作?用什么控件?先谢!!!
- 高手救急,当我在程序最后执行了Application.Terminate 以后,程序报错,不知何故,时有时无,在线等待!(Terminate后程序做了哪些事呀?)
DownX,DownY:Integer;procedure TForm1.FormMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
DownX:=x;
DownY:=Y;
end;
private
oldx, oldy: integer;
canmove: boolean;
{ Private declarations }
public
{ Public declarations }
//在这里声明也行
end;procedure Tfrmxmtp.Panel1MouseDown(Sender: TObject;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
if button = mbleft then
begin
canmove := true;
oldx := x;
oldy := y;
end;
end;procedure Tfrmxmtp.Panel1MouseMove(Sender: TObject;
Shift: TShiftState; X, Y: Integer);
begin
if canmove then
begin
panel1.Top := panel1.Top + y - oldy;
panel1.Left := panel1.Left + x - oldx;
if panel1.Left < 0 then
panel1.Left := 0;
if panel1.Top < 0 then
panel1.Top := 0;
if panel1.Top + panel1.Height > form1.Height then
panel1.Top := form1.Height - panel1.Height;
if panel1.Left + panel1.Width > form1.Width then
panel1.Left := form1.Width - panel1.Width;
end;
end;procedure Tfrmxmtp.Panel1MouseUp(Sender: TObject;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
canmove := false;
end;
DownX,DownY:Integer;procedure TForm1.FormMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
DownX:=x;
DownY:=Y;
end
来迟了 DownX,DownY为全局变量
p.y;
private
oldx, oldy: integer;
canmove: boolean;
x1,x2,y1,y2,l:int64;
{ Private declarations }
public
{ Public declarations }
//在这里声明也行
end;var
Form1: TForm1;implementation{$R *.dfm}Function js(x1,x2,y1,y2:int64):int64;
var
x,y:int64;
lengthl:real;
begin
x:=(x2-x1)*(x2-x1);
y:=(y2-y1)*(y2-y1);
lengthl := x+y ;
lengthl := sqrt(lengthl);
Result:=trunc(lengthl);
end;
procedure TForm1.Panel1MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
begin
if canmove then
begin
panel1.Top := panel1.Top + y - oldy;
panel1.Left := panel1.Left + x - oldx;
if panel1.Left < 0 then
panel1.Left := 0;
if panel1.Top < 0 then
panel1.Top := 0;
if panel1.Top + panel1.Height > form1.Height then
panel1.Top := form1.Height - panel1.Height;
if panel1.Left + panel1.Width > form1.Width then
panel1.Left := form1.Width - panel1.Width;
end;
end;procedure TForm1.Panel1MouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);begin
canmove := false;
x2:=panel1.Left;
y2:=panel1.Top;
l:=js(x1,x2,y1,y2);
showmessage(inttostr(l));
end;procedure TForm1.Panel1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
if button = mbleft then
begin
canmove := true;
oldx := x;
oldy := y;
x1:=panel1.Left;
y1:=panel1.Top;
end;
end;
begin
ReleaseCapture;
SendMessage(TWinControl(Sender).Handle, WM_NCLBUTTONDOWN, HTCAPTION, 0);
end;