10

InnoSetup by default displays the license agreement in a really tiny text area that the user can't make bigger in any way.

While I know most people don't read these, I feel that providing it in a format that makes it particularly hard to read is a bad idea, and might form part of a defense in court.

Is there any way in InnoSetup to display the license in a large separate window? A pre-rolled Pascal script perhaps?

Roman Starkov
  • 59,298
  • 38
  • 251
  • 324

3 Answers3

14

You can change the WizardForm size and rearrange the controls in it if you want to make it bigger. I made this example to show you how to change the form height for the License page.

[Setup]
AppName=StackOverflow large license box
AppVersion=1.0
CreateAppDir=no
DisableProgramGroupPage=yes
DefaultGroupName=My Program
UninstallDisplayIcon={app}\MyProg.exe
LicenseFile=license.txt
;OutputDir=userdocs:Inno Setup Examples Output

[Code]

var
  DefaultTop, 
  DefaultLeft, 
  DefaultHeight,
  DefaultBackTop, 
  DefaultNextTop, 
  DefaultCancelTop,
  DefaultBevelTop, 
  DefaultOuterHeight: Integer;

const 
  LicenseHeight = 600;

procedure InitializeWizard();
begin
  DefaultTop := WizardForm.Top;
  DefaultLeft := WizardForm.Left;
  DefaultHeight := WizardForm.Height;
  DefaultBackTop := WizardForm.BackButton.Top;
  DefaultNextTop := WizardForm.NextButton.Top;
  DefaultCancelTop := WizardForm.CancelButton.Top;
  DefaultBevelTop := WizardForm.Bevel.Top;
  DefaultOuterHeight := WizardForm.OuterNotebook.Height;

  WizardForm.InnerPage.Height := WizardForm.InnerPage.Height + (LicenseHeight - DefaultHeight);
  WizardForm.InnerNotebook.Height :=  WizardForm.InnerNotebook.Height + (LicenseHeight - DefaultHeight);
  WizardForm.LicensePage.Height := WizardForm.LicensePage.Height + (LicenseHeight - DefaultHeight);
  WizardForm.LicenseMemo.Height := WizardForm.LicenseMemo.Height + (LicenseHeight - DefaultHeight);
  WizardForm.LicenseNotAcceptedRadio.Top := WizardForm.LicenseNotAcceptedRadio.Top + (LicenseHeight - DefaultHeight);
  WizardForm.LicenseAcceptedRadio.Top := WizardForm.LicenseAcceptedRadio.Top + (LicenseHeight - DefaultHeight);

end;

procedure CurPageChanged(CurPageID: Integer);
begin
  if CurPageID = wpLicense then
  begin
    WizardForm.Top := DefaultTop - (LicenseHeight - DefaultHeight) div 2;
    WizardForm.Height := LicenseHeight;
    WizardForm.OuterNotebook.Height := WizardForm.OuterNotebook.Height + (LicenseHeight - DefaultHeight);
    WizardForm.CancelButton.Top := DefaultCancelTop + (LicenseHeight - DefaultHeight);
    WizardForm.NextButton.Top := DefaultNextTop + (LicenseHeight - DefaultHeight);
    WizardForm.BackButton.Top := DefaultBackTop + (LicenseHeight - DefaultHeight);
    WizardForm.Bevel.Top := DefaultBevelTop + (LicenseHeight - DefaultHeight);
  end
  else 
  begin
    WizardForm.Top := DefaultTop;
    WizardForm.Left := DefaultLeft;
    WizardForm.Height := DefaultHeight;
    WizardForm.OuterNotebook.Height := DefaultOuterHeight;
    WizardForm.CancelButton.Top := DefaultCancelTop;
    WizardForm.NextButton.Top := DefaultNextTop;
    WizardForm.BackButton.Top := DefaultBackTop;
    WizardForm.Bevel.Top := DefaultBevelTop;
  end;
end;

Copy it to a new iss file and provide a valid license.txt file in order to compile successfully. The script is tested with inno 5.4.0 but it should work with any 5.x.

jachguate
  • 16,976
  • 3
  • 57
  • 98
  • Just wanted to mention that we didn't use this in the end. The problem is that if the user moves the installer (say, to a different monitor), this code resets it back to default position. Which is quite annoying. I'll leave this accepted because it's the only answer that addresses the question, but I've posted the WordPad button code as a separate answer too. – Roman Starkov Jan 22 '12 at 10:28
4

Resizing the license box didn't work too well, so instead we ended up providing a button to view the license in WordPad. This works surprisingly well; I rather liked it in the end. Code:

procedure ViewLicenseButtonClick(Sender: TObject);
var WordpadLoc: String;
    RetCode: Integer;
begin
  RegQueryStringValue(HKLM, 'SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\WORDPAD.EXE', '', WordpadLoc);

  // on NT/2000 it's a REG_EXPAND_SZ, so expand constant ProgramFiles
  StringChange(WordpadLoc, '%ProgramFiles%', ExpandConstant('{pf}'));
  // remove " at begin and end pf string
  StringChange(WordpadLoc, '"', '');

  try
    ExtractTemporaryFile('LicenseAgreement.rtf')
  except
    MsgBox('Cannot extract license file.', mbError, mb_Ok);
  end;

  if not Exec(WordpadLoc, '"' + ExpandConstant('{tmp}\LicenseAgreement.rtf') + '"', '', SW_SHOW, ewNoWait, RetCode) then
    MsgBox('Cannot display license file.', mbError, mb_Ok);
end;

procedure CurPageChanged(CurPageID: Integer);
var ViewLicenseButton: TButton;
begin
  if CurPageID = wpLicense then begin
    ViewLicenseButton := TButton.Create(WizardForm.LicenseMemo.Parent);
    ViewLicenseButton.Caption := '&View in WordPad';
    ViewLicenseButton.Width := 120;
    ViewLicenseButton.Left := WizardForm.LicenseMemo.Left +
                        WizardForm.LicenseMemo.Width - ViewLicenseButton.Width;
    ViewLicenseButton.Top := WizardForm.LicenseMemo.Top +
                        WizardForm.LicenseMemo.Height + 16;
    ViewLicenseButton.OnClick := @ViewLicenseButtonClick;
    ViewLicenseButton.Parent := WizardForm.LicenseAcceptedRadio.Parent;
  end;
end;
Roman Starkov
  • 59,298
  • 38
  • 251
  • 324
  • If you use ShellExec it will lookup the app path for you, or you can just give it the pah to the rtf and it will open in the default application... – Anders Jan 22 '12 at 10:35
  • @Anders Didn't know about the former; as for the latter - I don't want MS Word to open where installed; that takes too long. – Roman Starkov Jan 22 '12 at 15:10
  • 1
    Another way might be to create a new window (using [`CreateCustomForm`](http://www.jrsoftware.org/ishelp/index.php?topic=isxfunc_createcustomform) function) and on this form put the [`TRichEditViewer`](http://www.jrsoftware.org/ishelp/topic_scriptclasses.htm#TRichEditViewer) control with accept/decline radio buttons and show this window modally. – TLama Jul 29 '12 at 09:20
1

If you use the LicenseFile directive than Inno expects a plain text or RTF file. If you provide an RTF file you can set the font and other simple formatting (bold, italic etc) as you wish.

Vicky
  • 12,934
  • 4
  • 46
  • 54