在Inno Setup的ProgressGauge栏下的wpInstalling页面上显示多幅图像(幻灯片) [英] Multiple images display (slideshow) on wpInstalling Page under ProgressGauge bar in Inno Setup

查看:119
本文介绍了在Inno Setup的ProgressGauge栏下的wpInstalling页面上显示多幅图像(幻灯片)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我准备了一个简单的脚本,可以在wpInstalling页面上的ProgressGauge栏下显示图像.

I have prepared simple script that displays image under ProgressGauge bar on wpInstalling Page.

但是...我需要更复杂的功能.

But... I need more complex functionality.

我需要显示多个图像,每个图像显示X个(例如7个)秒后(安装时间长于X秒*图片数量时循环显示),或者每个显示X个(例如10个)百分比后.我试图将显示的图像嵌入到ProgressGauge.Position中,但是失败了.

What I need is multiple images show, each after X (e.g. 7) seconds (with loop when installation longer then X secs * number of images) or each after X (e.g. 10) percent of installation. I have tried to embed images display in ProgressGauge.Position, but I failed.

这就是我所拥有的:

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张图像.

The goal is:
On the wpInstalling there should be X images displayed, every next per X seconds or after X percent of installation.

推荐答案

由于 ProgressGauge 没有进度更改事件,无法处理使用Windows API计时器所需的安装应用程序消息.不幸的是,此计时器需要一个您无法在Inno Setup脚本中定义的回调函数,因此您将需要一些外部库来为您完成此工作.但是,有一个 InnoCallback 库可以完全做到这一点.

Since the ProgressGauge has no progress change events and there is no way to process setup application messages you will need to use the Windows API timer. This timer needs a callback function which you can't define in Inno Setup script unfortunately so you will need some external library to do this job for you. However there's the InnoCallback library which can do exactly this.

对于以下代码,将 InnoCallback.dll 库复制到您的设置中目录,将此代码与您的Inno Setup脚本合并,并实现某种幻灯片放映页面,打开OnSlideTimer事件,该事件将被定期调用(每秒具有当前设置).

For the following code copy the InnoCallback.dll library into your setup directory, merge this code with your Inno Setup script and implement some kind of a slideshow page turning in the OnSlideTimer event which will be called periodically (with the current settings each second).

[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;

这篇关于在Inno Setup的ProgressGauge栏下的wpInstalling页面上显示多幅图像(幻灯片)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆