Rob*_*beN 7 inno-setup image slideshow pascalscript
我准备了简单的脚本,ProgressGauge在wpInstalling页面上的栏下显示图像.
但是......我需要更复杂的功能.
我需要的是多个图像显示,每个显示X(例如7)秒(安装时的循环时间超过X秒*图像数量)或每次安装后X(例如10%).我试图嵌入图像显示ProgressGauge.Position,但我失败了.
这是我有的:
procedure CurPageChanged(CurPageID: Integer);
var
  BmpFile: TBitmapImage;
begin
  ExtractTemporaryFile('01.bmp');
  ExtractTemporaryFile('02.bmp');
  ExtractTemporaryFile('03.bmp');
  if CurPageID = wpInstalling then
  begin
    BmpFile:= TBitmapImage.Create(WizardForm);
    BmpFile.Bitmap.LoadFromFile(ExpandConstant('{tmp}\01.bmp'));
    BmpFile.Width:= ScaleX(420);
    BmpFile.Height:= ScaleY(180);
    BmpFile.Left := WizardForm.ProgressGauge.Left + ScaleX(0); 
    BmpFile.Top := WizardForm.ProgressGauge.Top + ScaleY(35);
    // BmpFile.Parent:= WizardForm.InstallingPage;
    // BmpFile:= TBitmapImage.Create(WizardForm);
    // BmpFile.Bitmap.LoadFromFile(ExpandConstant('{tmp}\03.bmp'));
    // BmpFile.Width:= ScaleX(420);
    // BmpFile.Height:= ScaleY(400);
    // BmpFile.Left := WizardForm.ProgressGauge.Left + ScaleX(0); 
    // BmpFile.Top := WizardForm.ProgressGauge.Top + ScaleY(35);
    // BmpFile.Parent:= WizardForm.InstallingPage;  
    // BmpFile:= TBitmapImage.Create(WizardForm);
    // BmpFile.Bitmap.LoadFromFile(ExpandConstant('{tmp}\03.bmp'));
    // BmpFile.Width:= ScaleX(420);
    // BmpFile.Height:= ScaleY(400);
    // BmpFile.Left := WizardForm.ProgressGauge.Left + ScaleX(0); 
    // BmpFile.Top := WizardForm.ProgressGauge.Top + ScaleY(35);
    // BmpFile.Parent:= WizardForm.InstallingPage;
  end;
end;  
目标是:
在wpInstalling应该显示X图像,每隔X秒或在安装X%之后.
由于ProgressGauge没有进度更改事件且无法处理安装应用程序消息,因此您需要使用Windows API计时器.该定时器需要,你不能在Inno Setup的脚本定义很遗憾,所以你需要一些外部库来为你做这项工作的回调函数.然而,这个InnoCallback库可以做到这一点.
对于以下代码,将InnoCallback.dll库复制到您的安装目录中,将此代码与您的Inno Setup脚本合并,并实现某种类型的幻灯片页面,该页面将OnSlideTimer定期调用(每秒使用当前设置).
[Files]
Source: "InnoCallback.dll"; DestDir: "{tmp}"; Flags: dontcopy
[code]
var
  TimerID: Integer;
type
  TTimerProc = procedure(Wnd: HWND; Msg: UINT; TimerID: UINT_PTR; 
    SysTime: DWORD);
function WrapTimerProc(Callback: TTimerProc; ParamCount: Integer): LongWord;
  external 'wrapcallback@files:InnoCallback.dll stdcall';    
function SetTimer(hWnd: HWND; nIDEvent, uElapse: UINT;
  lpTimerFunc: UINT): UINT; external 'SetTimer@user32.dll stdcall';
function KillTimer(hWnd: HWND; uIDEvent: UINT): BOOL; 
  external 'KillTimer@user32.dll stdcall'; 
procedure OnSlideTimer(Wnd: HWND; Msg: UINT; TimerID: UINT_PTR; 
  SysTime: DWORD);
begin
  { here you can turn your slideshow pages; use some variable to store the }
  { current index of the slide you are on, note that this procedure is called }
  { periodically each 1000 ms (see below why), so here you can also check the }
  { progress value, if you want to }
end;
procedure StartSlideTimer;
var
  TimerCallback: LongWord;
begin
  TimerCallback := WrapTimerProc(@OnSlideTimer, 4);
  { third parameter here is the timer's timeout value in milliseconds }
  TimerID := SetTimer(0, 0, 1000, TimerCallback);
end;
procedure KillSlideTimer;
begin
  if TimerID <> 0 then 
  begin
    if KillTimer(0, TimerID) then
      TimerID := 0;
  end;
end;
function InitializeSetup: Boolean;
begin
  Result := True;
  TimerID := 0;
end;
procedure DeinitializeSetup;
begin
  KillSlideTimer;
end; 
procedure CurPageChanged(CurPageID: Integer);
begin
  if CurPageID = wpInstalling then
    StartSlideTimer
  else
    KillSlideTimer;
end;