我有一个面板(底部对齐)和一些控件(客户端对齐)。
为了使面板动画化,我使用:
AnimateWindow(Panel.Handle, 1000, aw_hide or AW_SLIDE OR AW_VER_POSITIVE);
panel.Visible:=false;
就我而言,面板会平滑地隐藏起来,然后其他控件才会占用它的空间。
但我希望其他控件能够在面板向下时平稳且同步地移动。
例如,FireFox就使用这种效果。
有人能给我推荐一些有用的东西吗?谢谢!
AnimateWindow
是一个同步函数,直到动画结束才会返回。这意味着在指定的时间内dwTime
参数,不会运行任何对齐代码,并且您的“alClient”对齐控件将保持静止,直到动画完成。
我建议改用计时器。举个例子:
type
TForm1 = class(TForm)
..
private
FPanelHeight: Integer;
FPanelVisible: Boolean;
..
procedure TForm1.FormCreate(Sender: TObject);
begin
FPanelHeight := Panel1.Height;
Timer1.Enabled := False;
Timer1.Interval := 10;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
Timer1.Enabled := True;
FPanelVisible := not FPanelVisible;
end;
procedure TForm1.Timer1Timer(Sender: TObject);
const
Diff: array [Boolean] of Integer = (-1, 1);
begin
Panel1.Height := Panel1.Height - Diff[FPanelVisible];
Panel1.Visible := Panel1.Height > 0;
Timer1.Enabled := (Panel1.Height > 0) and (Panel1.Height < FPanelHeight);
end;
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)