如何在Inno Setup中设置控件的动画

时间:2017-12-02 23:02:57

标签: inno-setup

我想在我的安装程序中设置控件的动画。

You can see this video

1 个答案:

答案 0 :(得分:1)

您可以使用计时器使用InnoTools InnoCallback DLL library

为控件设置动画
[Files]
Source: InnoCallback.dll; Flags: dontcopy

[Code]

type
  TTimerProc = procedure(H: LongWord; Msg: LongWord; IdEvent: LongWord; Time: LongWord);

function SetTimer(hWnd: longword; nIDEvent, uElapse: LongWord; lpTimerFunc: LongWord):
  LongWord; external 'SetTimer@user32.dll stdcall';
function KillTimer(hWnd, nIDEvent: LongWord): LongWord;
  external 'KillTimer@User32.dll stdcall';

function WrapTimerProc(Callback: TTimerProc; ParamCount: Integer): LongWord;
  external 'wrapcallback@files:innocallback.dll stdcall';

var
  MainPanelAnimated: Boolean;
  AnimationTimer: LongWord;

procedure AnimationTimerProc(
  H: LongWord; Msg: LongWord; IdEvent: LongWord; Time: LongWord);
var
  L: Integer;
begin
  L := WizardForm.MainPanel.Left + ScaleX(5);
  if L > 0 then
  begin
    L := 0;
    KillTimer(0, AnimationTimer);
  end;
  WizardForm.MainPanel.Left := L;
end;

procedure CurPageChanged(CurPageID: Integer);
var
  HoverTimerCallback: LongWord;
begin
  if WizardForm.OuterNotebook.ActivePage = WizardForm.InnerPage then
  begin
    if not MainPanelAnimated then
    begin
      HoverTimerCallback := WrapTimerProc(@AnimationTimerProc, 4);
      AnimationTimer := SetTimer(0, 0, 5, HoverTimerCallback);
      WizardForm.MainPanel.Left := -WizardForm.MainPanel.Width;
      MainPanelAnimated := True;
    end;
  end;
end;

enter image description here

(动画实际上比图像显示的更平滑)

对于从右到左的动画,请参阅Inno Setup - Animate a control roll out from right in a determinate page