0

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;

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.

Please help me.

user1752602
  • 423
  • 6
  • 19

1 Answers1

3

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;
TLama
  • 75,147
  • 17
  • 214
  • 392
  • When am using .gif files, other than .bmp files in above code showing belowRunTimeerror: Bitmap image is not valid – user1752602 May 13 '13 at 16:54
  • 1
    BackImage is TBitmapImage which does not allows to load .gif files. – Slappy May 13 '13 at 16:59
  • is any function to load .gif files? – user1752602 May 13 '13 at 17:05
  • In inno setup i can only see functions for bitmap files but i want a rotating image. so need gif file/image. – user1752602 May 13 '13 at 17:12
  • 1
    @user1752602, there's currently no support for files other than bitmaps, but it's a good idea for suggesting a new feature if someone else didn't already so. If there would be published Delphi's `TImage` class with `PNGImage`, `JPEG` and `GifImg` units included, all those file types would be supported. So from the implementation point of view it's very easy. – TLama May 13 '13 at 17:16
  • @TLama: Is any third party tools/files are available to display animated gif files on inno setup installer? – user1752602 May 15 '13 at 04:55
  • @user1752602, I don't know about any. I could publish the `TImage` with that support and make you a build of InnoSetup but it would be contraproductive since I don't have time to keep sync with every official InnoSetup build. – TLama May 15 '13 at 07:10
  • @TLama: Ok, i will try with the bitmap images only thanks for your help. – user1752602 May 15 '13 at 07:18
  • You're welcome! Anyway, this would be a good feature request (if it doesn't already exist) as many people asks for that. – TLama May 15 '13 at 07:38