0

I would like to understand how can I add a button on the welcome page, that once clicked it will open a specific website on the default web-browser.

I just would like to display a kind of picture control that can be pressed to perform an action (in this case, open the software's author website on the web-browser). I can store the image file in the 'embedded' or '{tmp}' directory. If the button can have PNG or ICO transparency it would be better for me, but its not a problem at all.

I would like the picture button to have a square form and to be located at the bottom-left corner like the orange square in this image, covering almost all that area with some width and height pixel margin:

enter image description here

I can manually resize the image file before compiling the setup, to fit the control's width/height, but I'm not sure if the control's size will have the same fixed size on all systems. Anyways I imagine that the control will have its built-in logic to resize at runtime the image to fit its control's size, or not?.

Additional to this, and if someone can help me, I also would like to understand how to add a custom text label and locate it where it says: "Installer made by {name}" (in that exact corner, that is at the right of the logo image panel and the bottom of the welcome page text box)

I'm asking for a generous code sample or instructions to guide me through the process to do this.

UPDATE:

Thanks to this little code example from the OP, and this documentation with the name of properties of TWizardForm class, and this tip I think that I managed to figure out how to do properly the label part.

[Code]

procedure InitializeWizard();
var
  InstallerAuthorLabel: TNewStaticText;
  
begin
    InstallerAuthorLabel         := TNewStaticText.Create(WizardForm);
    InstallerAuthorLabel.Caption := 'Installer by ElektroStudios';
    InstallerAuthorLabel.Parent  := WizardForm.WelcomePage;
    
    InstallerAuthorLabel.Left := (WizardForm.WizardBitmapImage.Left + WizardForm.WizardBitmapImage.Width) + ScaleX(8);
    InstallerAuthorLabel.Top  := (WizardForm.WizardBitmapImage.Top + WizardForm.WizardBitmapImage.Height) - ScaleY(20);

end;

It looks like this:

enter image description here

But I'm not sure about how to add a "picture button" on that same page and how to calculate its location because it seems that if I put a control under the WizardBitmapImage bottom height it gets hidden...

ElektroStudios
  • 19,105
  • 33
  • 200
  • 417

1 Answers1

0

Not sure if this code below is done in the correct way, but this is what I was able to do by myself after multiple researches and headaches since I'm a newbie on pascal scripting and of course I don't know almost any member of the Inno Setup classes references:

enter image description here

[Code]

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - //
// Opens the specified url in the default web-browser.     //
// https://stackoverflow.com/a/38934870/1248295            //
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - //
procedure OpenWebBrowser(Url: string);
var
  ErrorCode: Integer;
begin
  ShellExec('open', Url, '', '', SW_SHOWNORMAL, ewNoWait, ErrorCode);
end;

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - //
// Occurs when the AuthorWebsiteLabel and AuthorWebsiteBitmap control are clicked. //
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - //
procedure AuthorWebsiteControlClick(Sender: TObject);
begin
  OpenWebBrowser('{#AuthorWebsite}');
end;

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - //
// Use this event function to make changes to the wizard or wizard pages at startup. //
// At the time this event is triggered, the wizard form does not yet exist.          //
// https://jrsoftware.org/ishelp/index.php?topic=scriptevents                        //
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - //
<event('InitializeWizard')>
procedure InitializeWizard1();
var
  InstallerAuthorLabel: TNewStaticText;
  AuthorWebsiteLabel  : TNewStaticText;
  AuthorWebsiteBitmap : TBitmapImage;
  
begin
    // Set AuthorWebsiteBitmap control properties...
    AuthorWebsiteBitmap          := TBitmapImage.Create(WizardForm);
    AuthorWebsiteBitmap.Parent   := WizardForm.WelcomePage;
    AuthorWebsiteBitmap.AutoSize := True;
    AuthorWebsiteBitmap.Left     := (WizardForm.WizardBitmapImage.Left + WizardForm.WizardBitmapImage.Width) + ScaleX(10);
    AuthorWebsiteBitmap.Top      := (WizardForm.WelcomeLabel2.Top + WizardForm.WelcomeLabel2.Height) - (AuthorWebsiteBitmap.Height div 2) - ScaleX(16);
    AuthorWebsiteBitmap.Cursor   := crHand
    AuthorWebsiteBitmap.OnClick  := @AuthorWebsiteControlClick;
    ExtractTemporaryFile('AuthorWebsite.bmp');
    AuthorWebsiteBitmap.Bitmap.LoadFromFile(ExpandConstant('{tmp}\AuthorWebsite.bmp'));
        
    // Resize WelcomeLabel2 height to be able see AuthorWebsiteBitmap control.
    WizardForm.WelcomeLabel2.Height := WizardForm.WelcomeLabel2.Height - (AuthorWebsiteBitmap.Height + ScaleY(8));
    // This will not work...
    // AuthorWebsiteBitmap.BringToFront();
    
    // Set AuthorWebsiteLabel control properties...
    AuthorWebsiteLabel         := TNewStaticText.Create(WizardForm);
    AuthorWebsiteLabel.Caption := 'Navigate to author''s website...';
    AuthorWebsiteLabel.Parent  := WizardForm.WelcomePage;
    AuthorWebsiteLabel.Left    := AuthorWebsiteBitmap.Left;
    AuthorWebsiteLabel.Top     := AuthorWebsiteBitmap.Top - ScaleY(18);
    AuthorWebsiteLabel.Cursor  := crHand;
    AuthorWebsiteLabel.OnClick := @AuthorWebsiteControlClick;

    // Set InstallerAuthorLabel control properties...
    InstallerAuthorLabel         := TNewStaticText.Create(WizardForm);
    InstallerAuthorLabel.Caption := 'Installer created by ElektroStudios';
    InstallerAuthorLabel.Parent  := WizardForm;
    InstallerAuthorLabel.Left    := ScaleX(2);
    InstallerAuthorLabel.Top     := WizardForm.NextButton.Top + WizardForm.NextButton.Height div 2 + ScaleY(10) - ScaleY(2);

end;
Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992
ElektroStudios
  • 19,105
  • 33
  • 200
  • 417