目的
添加一個可以選中安裝模式的自定義頁面,如下圖:
快速安裝模式: 跳過安裝路徑選擇
自定義安裝模式:正常選擇安裝路徑
創建[Code]區段
-
[Code] 區段是一個指定Pascal腳本的可選區段。Pascal腳本可用於以多種方式自定義安裝程序或卸載。請注意,創建 Pascal 腳本並不容易,需要具備 Inno Setup 的經驗以及有關 Pascal 編程或至少類似編程語言的知識。
-
[Code] 區代碼:
[Code] //#########################安裝模式窗口屬性########################### var //模式選擇窗口 modePage:TwizardPage; //模式選擇窗口ID modePageID:Integer; //單選按鈕 RadioButton1, RadioButton2: TRadioButton; //標題 Lbl1, Lbl2: TNewStaticText; //#################################################################### //######################創建安裝模式選擇頁面########################## procedure CreateModPage; begin modePage := CreateCustomPage(wpInfoBefore, '選擇安裝類型', '請根據您的需要選擇安裝的類型'); modePageID:= modePage.ID; RadioButton1 := TRadioButton.Create(modePage); RadioButton1.Left := ScaleX(80); RadioButton1.Top := ScaleY(40); RadioButton1.Width := modePage.SurfaceWidth; RadioButton1.Height := ScaleY(17); RadioButton1.Caption := '快速安裝'; RadioButton1.Checked := True; RadioButton1.Parent := modePage.Surface; Lbl1 := TNewStaticText.Create(modePage); Lbl1.Left := ScaleX(95); Lbl1.Top := ScaleY(60); Lbl1.Width := ScaleX(250); Lbl1.Height := ScaleY(50); Lbl1.Caption := '按照簡易模式安裝軟件到您的電腦'; Lbl1.Parent := modePage.Surface; RadioButton2 := TRadioButton.Create(modePage); RadioButton2.Left := ScaleX(80); RadioButton2.Top := RadioButton1.Top + ScaleY(60); RadioButton2.Width := modePage.SurfaceWidth; RadioButton2.Height := ScaleY(17); RadioButton2.Caption := '自定義安裝'; RadioButton2.Checked := false; RadioButton2.Parent := modePage.Surface; Lbl2 := TNewStaticText.Create(modePage); Lbl2.Left := ScaleX(95); Lbl2.Top := Lbl1.Top + ScaleY(60); Lbl2.Width := ScaleX(250); Lbl2.Height := ScaleY(50); Lbl2.Caption := '您可以手動配置安裝目錄'; Lbl2.Parent := modePage.Surface; end; //################################################################### //##############################初始化引導窗口####################### procedure InitializeWizard(); begin //創建模式選擇頁面 CreateModPage; end; //################################################################### //#############################滿足條件跳過窗口###################### function ShouldSkipPage(PageID: Integer): Boolean; var selectPage: TwizardPage; begin Result := False; if RadioButton1.Checked then begin case PageID of //路徑選擇頁面 wpSelectDir: Result := True; end; end; end; //#####################################################################
-
部分方法解釋
-
向導頁面(頁面ID對應意思):
字段 說明 wpWelcome 歡迎頁 wpLicense 許可協議 wpPassword 密碼 wpInfoBefore 信息 wpUserInfo 用戶信息 wpSelectDir 選擇目標位置 wpSelectComponents 選擇組件 wpSelectProgramGroup 選擇開始菜單文件夾 wpSelectTasks 選擇任務 wpReady 准備安裝 wpPreparing 正在准備安裝 wpInstalling 正在安裝 wpInfoAfter 信息 wpFinished 安裝完成 -
InitializeWizard:
procedure InitializeWizard();
在啟動時使用該事件函數來改變向導或向導頁面。你不能在它被觸發時使用 InitializeSetup 事件函數,因為向導窗體尚不存在。
-
CreateCustomPage:
function CreateCustomPage(const AfterID: Integer; const ACaption, ADescription: String): TWizardPage;
創建一個自定義向導頁面。這個頁面默認是空的;你可以創建自己的控件,然后放置到頁面中(通過設置它們的上級屬性為由這個函數返回的 TWizardPage 界面屬性實例)。
參數:
AfterID: 在哪個頁面ID之前顯示
ACaption: 說明文字
ADescription:詳細描述 -
ShouldSkipPage:
function ShouldSkipPage(PageID: Integer): Boolean;
向導調用這個事件函數確定是否在所有頁面或不在一個特殊頁面(用 PageID 指定)顯示。如果返回 True,將跳過該頁面;如果你返回 False,該頁面被顯示。
-