简体   繁体   English

使用 inno setup 自定义安装

[英]Custom installation using inno setup

HERE is My code这是我的代码

[Code]
var
  FullRadioButton: TNewRadioButton;
  PartRadioButton: TNewRadioButton;
  CustomPage: TWizardPage;
  UserInputsPage: TInputQueryWizardPage;
  FullDescLabel: TLabel;
  PartDescLabel: TLabel;
  url: String;

const
  FullDescText ='Full Installation.';
  PartDescText ='Partial Installation.';

procedure InitializeWizard; 
begin
  CustomPage := CreateCustomPage(wpWelcome, 'Installation type', '');
  FullRadioButton := TNewRadioButton.Create(WizardForm);
  FullRadioButton.Parent := CustomPage.Surface;
  FullRadioButton.Top := 16;
  FullRadioButton.Width := CustomPage.SurfaceWidth;
  FullRadioButton.Font.Style := [fsBold];
  FullRadioButton.Font.Size := 9;
  FullRadioButton.Caption := 'Default Installation'
  FullDescLabel := TLabel.Create(WizardForm);
  FullDescLabel.Parent := CustomPage.Surface;
  FullRadioButton.Checked := True;
  FullDescLabel.Left := 8;
  FullDescLabel.Top := FullRadioButton.Top + FullRadioButton.Height + 8;
  FullDescLabel.Width := CustomPage.SurfaceWidth; 
  FullDescLabel.Height := 40;
  FullDescLabel.AutoSize := False;
  FullDescLabel.Wordwrap := True;
  FullDescLabel.Caption := FullDescText;
  PartRadioButton := TNewRadioButton.Create(WizardForm);
  PartRadioButton.Parent := CustomPage.Surface;
  //PartRadioButton.Checked := True
  PartRadioButton.Top := FullDescLabel.Top + FullDescLabel.Height + 16;
  PartRadioButton.Width := CustomPage.SurfaceWidth;
  PartRadioButton.Font.Style := [fsBold];
  PartRadioButton.Font.Size := 9;
  PartRadioButton.Caption := 'Custom Installation'
  PartDescLabel := TLabel.Create(WizardForm);
  PartDescLabel.Parent := CustomPage.Surface;
  PartDescLabel.Left := 8;
  PartDescLabel.Top := PartRadioButton.Top + PartRadioButton.Height + 8;
  PartDescLabel.Width := CustomPage.SurfaceWidth;
  PartDescLabel.Height := 40;
  PartDescLabel.AutoSize := False;
  PartDescLabel.Wordwrap := True;
  PartDescLabel.Caption := PartDescText;
end;

function NextButtonClick(CurPageID: Integer): Boolean;
begin
if (PartRadioButton.Checked) then
    UserInputsPage := CreateInputQueryPage(wpWelcome,
          'Url information', 'Url',
          'Please specify the following informat, then click Next.');
    
    UserInputsPage.Add('URL:', False);
    UserInputsPage.Values[0] := ExpandConstant('');
  if(CurPageID = UserInputsPage.ID) then;
  begin
    url := UserInputsPage.Values[0];
    SaveStringToFile('path', 'user_input='+'"'+url+'"'+#13#10,True);
  end;
 Result := True;
end;            

Please help me out Thanks in advance!请帮帮我 在此先感谢!

I have code which is used for custom installation using inno setup, In this I have 2 radio button if user selects first radio button it should show user input text box and text to be save in file.我有用于使用 inno setup 进行自定义安装的代码,如果用户选择第一个单选按钮,我有 2 个单选按钮,它应该显示用户输入文本框和要保存在文件中的文本。 If user select next radio button it should not to do如果用户 select 下一个单选按钮不应该这样做

Use TWizardPage.OnShouldSkipPage event (or ShouldSkipPage event function ) to conditionally skip your custom page.使用TWizardPage.OnShouldSkipPage事件(或ShouldSkipPage事件 function )有条件地跳过您的自定义页面。

The custom page should better also be created (unconditionally) in the InitializeWizard , not in the NextButtonClick (the NextButtonClick can be called multiple times for the same page, if the user returns back).自定义页面最好也(无条件地)在InitializeWizard中创建,而不是在NextButtonClick中创建(如果用户返回,则可以为同一页面多次调用NextButtonClick )。

Additionally, the UserInputsPage must show after the CustomPage .此外, UserInputsPage必须显示在CustomPage之后。 While you are currently constructing it to show before.当您当前正在构建它以显示之前。 For that, pass CustomPage.ID as the first argument of the CreateInputQueryPage .为此,将CustomPage.ID作为CreateInputQueryPage的第一个参数传递。

function UserInputsPageShouldSkipPage(Sender: TWizardPage): Boolean;
begin
  Result := not PartRadioButton.Checked;
end;
UserInputsPage :=
  CreateInputQueryPage(
    CustomPage.ID, 'Url information', 'Url',
    'Please specify the following informat, then click Next.');
// ...
UserInputsPage.OnShouldSkipPage := @UserInputsPageShouldSkipPage;

Similar questions:类似问题:


Also, you should not do any changes to the user's system, before the user confirms the installation.此外,在用户确认安装之前,您不应该对用户的系统进行任何更改。 So typically, you do not want call SaveStringToFile when user click Next on the custom page (not to mention again that it can happen multiple times, if user returns back).因此,通常情况下,当用户在自定义页面上单击“下一步”时,您不希望调用SaveStringToFile (更不用说如果用户返回,它可能会发生多次)。 Better use CurStepChanged for ssInstall or ssPostInstall step.最好将CurStepChanged用于ssInstallssPostInstall步骤。

And your NextButtonClick code is wrong anyway, due to the semicolon after the then .由于then之后的分号,您的NextButtonClick代码无论如何都是错误的。 Effectively you call SaveStringToFile on each and every page of the wizard.实际上,您可以在向导的每一页上调用SaveStringToFile

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM