Inno Setup - display a message in separate window

2019-06-14 14:10发布

问题:

I already used InfoBeforeFile directive, with an "Important notice" text file.

But I would prefer the user could continue to read the instructions throughout an installation (e.g. in a separate window).

Any clue?


Added the final result, thanks again to Martin Prikryl

回答1:

Use CreateCustomForm function to create a separate window for your message.

[Files]
Source: "important.txt"; Flags: dontcopy;

[Code]

procedure InitializeWizard();
var
  InfoForm: TSetupForm;
  InfoMemo: TRichEditViewer;
begin
  InfoForm := CreateCustomForm;
  Log(IntToStr(WizardForm.Left));
  Log(IntToStr(WizardForm.Width));
  InfoForm.Left := WizardForm.Left + WizardForm.Width; 

  InfoForm.Width := ScaleX(400); 
  InfoForm.Caption := 'Important message';
  InfoForm.Top := WizardForm.Top;
  InfoForm.Height := WizardForm.Height;
  InfoForm.Position := poDesigned;
  InfoForm.Show();

  InfoMemo := TRichEditViewer.Create(InfoForm);
  InfoMemo.Parent := InfoForm;
  InfoMemo.Left := ScaleX(40);
  InfoMemo.Top := ScaleX(40);
  InfoMemo.Width := InfoForm.ClientWidth - 2 * ScaleX(40);
  InfoMemo.Height := InfoForm.ClientHeight - 2 * ScaleX(40);
  InfoMemo.ScrollBars := ssVertical;
  InfoMemo.ReadOnly := ssVertical;
  InfoMemo.WantReturns := ssVertical;
  InfoMemo.WantReturns := False;

  ExtractTemporaryFile('important.txt');
  InfoMemo.Lines.LoadFromFile(ExpandConstant('{tmp}\important.txt'));
end;



标签: inno-setup