Welcome Label Transparent on Inno Setup

2020-02-05 05:10发布

问题:

How do I WelcomeLabel on Inno Setup does not appear and leave only the text over the image.

This is that i want.

回答1:

Something like this might do the trick. Since the welcome labels don't support transparency, you need to workaround this by creating your own with a different class (that has a transparency support), inherit the parent, font, text and size and hide the original ones. Here is the script how to do this:

[Code]
procedure InheritBoundsRect(ASource, ATarget: TControl);
begin
  ATarget.Left := ASource.Left;
  ATarget.Top := ASource.Top;
  ATarget.Width := ASource.Width;
  ATarget.Height := ASource.Height;
end;

procedure InitializeWizard;
var
  TopWelcomeLabel: TLabel;
  BottomWelcomeLabel: TLabel;
begin
  WizardForm.WizardBitmapImage.Align := alClient;
  WizardForm.WizardBitmapImage.Bitmap.LoadFromFile('D:\Image.bmp');

  TopWelcomeLabel := TLabel.Create(WizardForm);
  TopWelcomeLabel.Parent := WizardForm.WelcomeLabel1.Parent;
  TopWelcomeLabel.Font := WizardForm.WelcomeLabel1.Font;
  TopWelcomeLabel.Caption := WizardForm.WelcomeLabel1.Caption;
  TopWelcomeLabel.WordWrap := WizardForm.WelcomeLabel1.WordWrap;
  InheritBoundsRect(WizardForm.WelcomeLabel1, TopWelcomeLabel);
  WizardForm.WelcomeLabel1.Visible := False;

  BottomWelcomeLabel := TLabel.Create(WizardForm);
  BottomWelcomeLabel.Parent := WizardForm.WelcomeLabel2.Parent;
  BottomWelcomeLabel.Font := WizardForm.WelcomeLabel2.Font;
  BottomWelcomeLabel.Caption := WizardForm.WelcomeLabel2.Caption;
  BottomWelcomeLabel.WordWrap := WizardForm.WelcomeLabel2.WordWrap;
  InheritBoundsRect(WizardForm.WelcomeLabel2, BottomWelcomeLabel);
  WizardForm.WelcomeLabel2.Visible := False;
end;

And the result:



回答2:

I'm afraid what you want may not be possible or rather difficult, even if creating a custom page. Have a look at the CreateCustomPage() function and the example scripts included with your Inno Setup installation.



回答3:

This code can help you. Just change the Welcome page, but you can try with other pages of the installer.

[code]
function NextButtonClick(CurPageID: Integer): Boolean;
begin
  Result := True;
end;

function GetCustomSetupExitCode(): Integer;
begin
  Result := 1;
end;

procedure InitializeWizard();
var
  WLabel1, WLabel2,
  FLabel1, FLabel2: TLabel;
begin
  WizardForm.WelcomeLabel1.Hide;
  WizardForm.WelcomeLabel2.Hide;
  WizardForm.FinishedHeadingLabel.Hide;
  WizardForm.FinishedLabel.Hide;
  WizardForm.WizardBitmapImage.Width := 500;
  WizardForm.WizardBitmapImage.Height := 315;

  WLabel1 := TLabel.Create(WizardForm);
  WLabel1.Left := ScaleX(176); 
  WLabel1.Top := ScaleY(16);
  WLabel1.Width := ScaleX(301); 
  WLabel1.Height := ScaleY(54); 
  WLabel1.AutoSize := False;
  WLabel1.WordWrap := True;
  WLabel1.Font.Name := 'verdana'; 
  WLabel1.Font.Size := 12; 
  WLabel1.Font.Style := [fsBold];
  WLabel1.Font.Color:= clBlack; 
  WLabel1.ShowAccelChar := False;
  WLabel1.Caption := WizardForm.WelcomeLabel1.Caption;
  WLabel1.Transparent := True;
  WLabel1.Parent := WizardForm.WelcomePage;

  WLabel2 :=TLabel.Create(WizardForm);
  WLabel2.Top := ScaleY(76);
  WLabel2.Left := ScaleX(176); 
  WLabel2.Width := ScaleX(301); 
  WLabel2.Height := ScaleY(234); 
  WLabel2.AutoSize := False;
  WLabel2.WordWrap := True;
  WLabel2.Font.Name := 'tahoma'; 
  WLabel2.Font.Color:= clBlack; 
  WLabel2.ShowAccelChar := False;
  WLabel2.Caption := WizardForm.WelcomeLabel2.Caption;
  WLabel2.Transparent := True;
  WLabel2.Parent := WizardForm.WelcomePage;

  WizardForm.WizardBitmapImage2.Width := 500; 
  WizardForm.WizardBitmapImage2.Height := 315; 

  FLabel1 := TLabel.Create(WizardForm); 
  FLabel1.Left := ScaleX(176); 
  FLabel1.Top := ScaleY(16);
  FLabel1.Width := ScaleX(301); 
  FLabel1.Height := ScaleY(54); 
  FLabel1.AutoSize := False;
  FLabel1.WordWrap := True;
  FLabel1.Font.Name := 'verdana'; 
  FLabel1.Font.Size := 12; 
  FLabel1.Font.Style := [fsBold];
  FLabel1.Font.Color:= clBlack; 
  FLabel1.ShowAccelChar := False;
  FLabel1.Caption := WizardForm.FinishedHeadingLabel.Caption;
  FLabel1.Transparent := True;
  FLabel1.Parent := WizardForm.FinishedPage;

  FLabel2 :=TLabel.Create(WizardForm);
  FLabel2.Top := ScaleY(76);
  FLabel2.Left := ScaleX(176); 
  FLabel2.Width := ScaleX(301); 
  FLabel2.Height := ScaleY(53); 
  FLabel2.AutoSize := False;
  FLabel2.WordWrap := True;
  FLabel2.Font.Name := 'tahoma'; 
  FLabel2.Font.Color:= clBlack; 
  FLabel2.ShowAccelChar := False;
  FLabel2.Caption := WizardForm.FinishedLabel.Caption;
  FLabel2.Transparent := True;
  FLabel2.Parent := WizardForm.FinishedPage;
end;


标签: inno-setup