可转载 请 标注 来源
procedure TForm4.FormCreate(Sender: TObject);
begin
FOldPostion := TStringList.Create;
end;
procedure TForm4.HideAllControl(vshow: boolean);
var
i, j,x: Integer;
y, k: Single;
begin
if not vshow then
begin
FOldPostion.Clear;
for i := 0 to ComponentCount - 1 do
begin
if Components[i] is TControl then
begin
y := (Components[i] as TControl).Position.y;
FOldPostion.Values[(Components[i] as TControl).Name] := y.ToString();
j := Round(y);
x := 1;
repeat
(Components[i] as TControl).Position.y := j;
(Components[i] as TControl).Opacity := j / 10;
Sleep(3);
Application.ProcessMessages;
Updated;
inc(j, x); //速度
inc(x);
until j >= ClientHeight;
(Components[i] as TControl).Visible := vshow;
end;
end;
end
else
begin
for i := 0 to ComponentCount - 1 do
begin
if Components[i] is TControl then
begin
(Components[i] as TControl).Visible := vshow;
y := 0;
x := 1;
j := Round(y);
k := StrToInt(FOldPostion.Values[(Components[i] as TControl).Name]);
repeat
(Components[i] as TControl).Position.y := j;
(Components[i] as TControl).Opacity := j / 10;
Sleep(3);
Application.ProcessMessages;
Updated;
inc(j, x);
Inc(x);
until j >= k;
end;
end;
end;
end;
procedure TForm4.Button1Click(Sender: TObject);
begin
TThread.CreateAnonymousThread(
procedure
begin
HideAllControl(False);
HideAllControl(true);
end).Start;
end;