修改工程文件
program Project1;
uses
Forms,
SysUtils,
Unit1 in 'Unit1.pas' {Form1};
{$R *.res}
procedure MoveForm(Form: TForm; L, T, W, H: Integer);
var
I, DL, DT, DW, DH, DX: Integer;
procedure SetDX(Int: Integer);
begin
if (Int <> 0) and ((DX > Abs(Int)) or (DX = 0)) then
DX := Abs(Int);
end;
begin
DL := L - Form.Left;
DT := T - Form.Top;
DW := W - Form.Width;
DH := H - Form.Height;
DX := 0;
SetDX(DL);
SetDX(DT);
SetDX(DW);
SetDX(DH);
DX := DX div 3; //3,这个数字可以决定移动的快慢,数字越大移动越快
if DX = 0 then Exit; //说明位置大小都相同,无需移动
DL := Round(DL / DX);
DT := Round(DT / DX);
DW := Round(DW / DX);
DH := Round(DH / DX);
with Form do
begin
Show;
//AutoScroll := False;
for I := 0 to DX do
begin
SetBounds(Left + DL, Top + DT, Width + DW, Height + DH);
Update;
end;
SetBounds(L, T, W, H);
//AutoScroll := True;
end;
end;
begin
Application.Initialize;
Application.CreateForm(TForm1, Form1);
Form1.SetBounds(10, 10, 100, 50);
MoveForm(Form1, (Screen.WorkAreaWidth - 600) div 2, (Screen.WorkAreaHeight - 400) div 2, 600, 400);
Sleep(1000);
MoveForm(Form1, 10, 10, 100, 50);
Application.Run;
end.