How to animate a control roll out in Inno Setup

2019-04-15 23:41发布

问题:

I want to animate a control roll out in my installer.

You can see this video.

回答1:

You can use a timer to animate a control using 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;

(the animation is actually more smooth than the image shows)

For right-to-left animation, see Inno Setup - Animate a control roll out from right in a determinate page.



标签: inno-setup