我们使用下面的代码在完成页面上显示图像(幻灯片)。
[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。
请帮我。