Adding a help button to an InnoSetup wizard page

核能气质少年 提交于 2020-01-11 04:02:05

问题


I have a setup script with a custom wizard page to get a choice from the user. It would be nice to have a help button and to supply a small CHM file with the installable so that I can provide a detailed explanation of what the choices are.

Anyone know whether there is an easy way to do this?


回答1:


See this post for details on how to include a file with the installation package and reference that file before installation has started.

To add a button to the install wizard, I included the following code in the InitializeWizard event handler.

procedure CreateHelpButton (ParentForm   : TSetupForm ; 
                            X            : integer ;
                            Y            : integer ;
                            W            : integer ;
                            H            : integer) ;

var
  HelpButton : TNewButton ;
begin
  HelpButton         := TNewButton.Create (ParentForm) ;
  HelpButton.Left    := X ;
  HelpButton.Top     := Y ;
  HelpButton.Width   := W ;
  HelpButton.Height  := H ;
  HelpButton.Caption := '&Help' ;
  HelpButton.OnClick := @HelpButtonOnClick ;
  HelpButton.Parent  := ParentForm ;
end;

procedure InitializeWizard () ;

begin
  CreateHelpButton (
    WizardForm, ScaleX (20), WizardForm.CancelButton.Top,
    WizardForm.CancelButton.Width, WizardForm.CancelButton.Height) ;
end;  



回答2:


Just to complete the listing:

procedure HelpButtonOnClick(Sender: TObject);
var
  ResultCode: Integer;
begin
  ExtractTemporaryFile('installer.chm');

  if (FileExists(ExpandConstant('{tmp}\installer.chm'))) then
  begin
    ShellExec('', ExpandConstant('{tmp}\installer.chm'), '', ExpandConstant('{tmp}'), SW_SHOW, ewNoWait, ResultCode);
  end;
end;


来源:https://stackoverflow.com/questions/5658488/adding-a-help-button-to-an-innosetup-wizard-page

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!