创新设置:使用计时器显示图像 [英] Inno setup: Display Images using timer

查看:55
本文介绍了创新设置:使用计时器显示图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们使用下面的代码在完成"页面上显示图像(幻灯片).

We are using below code to display images(slide show) on Finished page.

[Setup]
AppName=My Program
AppVersion=1.5
DefaultDirName={pf}\My Program
OutputDir=userdocs:Inno Setup Examples Output

[Files]
Source: "Image1.bmp"; Flags: dontcopy
Source: "Image2.bmp"; Flags: dontcopy
Source: "Image3.bmp"; Flags: dontcopy
Source: "InnoCallback.dll"; Flags: dontcopy

[Code]
var
  TimerID: Integer;
  SlideID: Integer;
  BackImage: TBitmapImage;
  Panel: TPanel;

type
  TTimerProc = procedure(Wnd: HWND; Msg: UINT; TimerID: UINT_PTR; SysTime: DWORD);
  TDirectShowEventProc = procedure(EventCode, Param1, Param2: Integer);

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 URLOnClick(Sender: TObject);
var
  ErrorCode: Integer;
begin

  ShellExec('open', 'http://www.google.com/', '', '', SW_SHOW, ewWaitUntilTerminated,  ErrorCode);

end;

procedure OnSlideTimer(Wnd: HWND; Msg: UINT; TimerID: UINT_PTR; SysTime: DWORD);
begin
  case SlideID of 
    0: SlideID := 1;
    1: SlideID := 2;
    2: SlideID := 0;
  end;
  BackImage.Bitmap.LoadFromFile(ExpandConstant('{tmp}\Image' + IntToStr(SlideID + 1) + '.bmp'));
 end;

procedure StartSlideTimer;
var
  TimerCallback: LongWord;
begin
  TimerCallback := WrapTimerProc(@OnSlideTimer, 4);

  TimerID := SetTimer(0, 0, 2000, TimerCallback);
 end;


 procedure InitializeWizard;  
var
ContentHeight: Integer;
begin
  TimerID := 0;
  SlideID := 0;
  ContentHeight := WizardForm.OuterNotebook.Top + WizardForm.OuterNotebook.Height;
  ExtractTemporaryFile('Image1.bmp');
  ExtractTemporaryFile('Image2.bmp');
  ExtractTemporaryFile('Image3.bmp');

  Panel := TPanel.Create(WizardForm);
  Panel.Parent := WizardForm;
  Panel.Left := 200;
  Panel.Top := WizardForm.OuterNotebook.Top + 200;
  Panel.Width := ScaleX(220);
  Panel.Height := ScaleY(40);
  Panel.Visible := False;

  BackImage := TBitmapImage.Create(WizardForm);
  BackImage.Parent := Panel;
  BackImage.Width:= ScaleX(210);
  BackImage.Height:= ScaleY(35);
  BackImage.Left := (Panel.Height - BackImage.Height) div 2;
  BackImage.Top := (Panel.Height - BackImage.Height) div 2;
  BackImage.Bitmap.LoadFromFile(ExpandConstant('{tmp}\Image1.bmp'));
  BackImage.OnClick := @URLOnClick; 
  StartSlideTimer;
end;

procedure CurPageChanged(CurPageID: Integer);
begin
  Panel.Visible := CurPageID = wpFinished;
end;

我的问题是,这里的图像每2秒更改一次.如果单击Image1,则应打开google.com;如果单击Image2,则应打开Yahoo.com.

My question is, Here images will change for every 2 seconds. If i click on Image1, it should open google.com and if i click on Image2, it should open Yahoo.com.

请帮助我.

推荐答案

您知道SlideID变量中显示了哪张幻灯片,并且具有名为URLOnClick的图像点击事件方法(对于此类事件不是很好的名称顺便说一句).因此,只需以这种方式修改该事件方法:

You know which slide is shown in the SlideID variable and you're having image click event method called URLOnClick (not a good name for such event method btw.). So just modify that event method this way:

procedure URLOnClick(Sender: TObject);
var
  URL: string;
  ErrorCode: Integer;
begin
  URL := '';
  case SlideID of
    0: URL := 'http://www.google.com/'; // <- Image1
    1: URL := 'http://www.yahoo.com/'; // <- Image2
  end;
  if URL <> '' then
    ShellExec('open', URL, '', '', SW_SHOW, ewWaitUntilTerminated,  ErrorCode);
end;

这篇关于创新设置:使用计时器显示图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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