簡體   English   中英

使用 inno setup 自定義安裝

[英]Custom installation using inno setup

這是我的代碼

[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;            

請幫幫我 在此先感謝!

我有用於使用 inno setup 進行自定義安裝的代碼,如果用戶選擇第一個單選按鈕,我有 2 個單選按鈕,它應該顯示用戶輸入文本框和要保存在文件中的文本。 如果用戶 select 下一個單選按鈕不應該這樣做

使用TWizardPage.OnShouldSkipPage事件(或ShouldSkipPage事件 function )有條件地跳過您的自定義頁面。

自定義頁面最好也(無條件地)在InitializeWizard中創建,而不是在NextButtonClick中創建(如果用戶返回,則可以為同一頁面多次調用NextButtonClick )。

此外, UserInputsPage必須顯示在CustomPage之后。 當您當前正在構建它以顯示之前。 為此,將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;

類似問題:


此外,在用戶確認安裝之前,您不應該對用戶的系統進行任何更改。 因此,通常情況下,當用戶在自定義頁面上單擊“下一步”時,您不希望調用SaveStringToFile (更不用說如果用戶返回,它可能會發生多次)。 最好將CurStepChanged用於ssInstallssPostInstall步驟。

由於then之后的分號,您的NextButtonClick代碼無論如何都是錯誤的。 實際上,您可以在向導的每一頁上調用SaveStringToFile

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM