例子:在欢迎界面添加安装方式的选择
优质
小牛编辑
136浏览
2023-12-01
引用脚本的内容:
SetCompressor /SOLID lzma SetCompressorDictSize 32 XPStyle on Name "Welcome_setuptype" OutFile "Welcome_setuptype.exe" !include "MUI.nsh" !include "LogicLib.nsh" !include "WinMessages.nsh" InstallDir "$DESKTOP" ;页面自定义函数 !define MUI_PAGE_CUSTOMFUNCTION_PRE Pre !define MUI_PAGE_CUSTOMFUNCTION_SHOW Show ;!define MUI_PAGE_CUSTOMFUNCTION_LEAVE leave !insertmacro MUI_PAGE_WELCOME !define MUI_PAGE_CUSTOMFUNCTION_PRE compre !insertmacro MUI_PAGE_COMPONENTS !define MUI_PAGE_CUSTOMFUNCTION_PRE dirpre !insertmacro MUI_PAGE_DIRECTORY !insertmacro MUI_PAGE_INSTFILES !insertmacro MUI_LANGUAGE "SimpChinese" Function pre !insertmacro MUI_INSTALLOPTIONS_READ $0 "ioSpecial.ini" "Settings" "Numfields" ;读取控件数目 IntOp $R0 $0 + 4 ;添加4个控件 !insertmacro MUI_INSTALLOPTIONS_WRITE "ioSpecial.ini" "Field 3" "Text" "这个向导将指引你完成安装:" !insertmacro MUI_INSTALLOPTIONS_WRITE "ioSpecial.ini" "Field 3" "Bottom" "60" ;修小原有的文字框,避免遮盖 !insertmacro MUI_INSTALLOPTIONS_WRITE "ioSpecial.ini" "Settings" "Numfields" "$R0" !insertmacro MUI_INSTALLOPTIONS_WRITE "ioSpecial.ini" "Field 4" "Type" "RadioButton" !insertmacro MUI_INSTALLOPTIONS_WRITE "ioSpecial.ini" "Field 4" "State" "1" !insertmacro MUI_INSTALLOPTIONS_WRITE "ioSpecial.ini" "Field 4" "Text" "标准安装" !insertmacro MUI_INSTALLOPTIONS_WRITE "ioSpecial.ini" "Field 4" "Flags" "" !insertmacro MUI_INSTALLOPTIONS_WRITE "ioSpecial.ini" "Field 4" "Left" "120" !insertmacro MUI_INSTALLOPTIONS_WRITE "ioSpecial.ini" "Field 4" "Right" "168" !insertmacro MUI_INSTALLOPTIONS_WRITE "ioSpecial.ini" "Field 4" "Top" "70" !insertmacro MUI_INSTALLOPTIONS_WRITE "ioSpecial.ini" "Field 4" "Bottom" "85" !insertmacro MUI_INSTALLOPTIONS_WRITE "ioSpecial.ini" "Field 5" "Type" "RadioButton" !insertmacro MUI_INSTALLOPTIONS_WRITE "ioSpecial.ini" "Field 5" "State" "0" !insertmacro MUI_INSTALLOPTIONS_WRITE "ioSpecial.ini" "Field 5" "Text" "自定义安装" !insertmacro MUI_INSTALLOPTIONS_WRITE "ioSpecial.ini" "Field 5" "Flags" "" !insertmacro MUI_INSTALLOPTIONS_WRITE "ioSpecial.ini" "Field 5" "Left" "120" !insertmacro MUI_INSTALLOPTIONS_WRITE "ioSpecial.ini" "Field 5" "Right" "178" !insertmacro MUI_INSTALLOPTIONS_WRITE "ioSpecial.ini" "Field 5" "Top" "120" !insertmacro MUI_INSTALLOPTIONS_WRITE "ioSpecial.ini" "Field 5" "Bottom" "135" !insertmacro MUI_INSTALLOPTIONS_WRITE "ioSpecial.ini" "Field 6" "Type" "Label" !insertmacro MUI_INSTALLOPTIONS_WRITE "ioSpecial.ini" "Field 6" "Text" "本软件将安装到:\r\nC:\\Program Files\\software" !insertmacro MUI_INSTALLOPTIONS_WRITE "ioSpecial.ini" "Field 6" "Left" "130" !insertmacro MUI_INSTALLOPTIONS_WRITE "ioSpecial.ini" "Field 6" "Right" "250" !insertmacro MUI_INSTALLOPTIONS_WRITE "ioSpecial.ini" "Field 6" "Top" "90" !insertmacro MUI_INSTALLOPTIONS_WRITE "ioSpecial.ini" "Field 6" "Bottom" "110" !insertmacro MUI_INSTALLOPTIONS_WRITE "ioSpecial.ini" "Field 7" "Type" "Label" !insertmacro MUI_INSTALLOPTIONS_WRITE "ioSpecial.ini" "Field 7" "Text" "自定义所有的安装选项,推荐有经验的用户使用" !insertmacro MUI_INSTALLOPTIONS_WRITE "ioSpecial.ini" "Field 7" "Left" "130" !insertmacro MUI_INSTALLOPTIONS_WRITE "ioSpecial.ini" "Field 7" "Right" "300" !insertmacro MUI_INSTALLOPTIONS_WRITE "ioSpecial.ini" "Field 7" "Top" "140" !insertmacro MUI_INSTALLOPTIONS_WRITE "ioSpecial.ini" "Field 7" "Bottom" "150" FunctionEnd Function show Push $0 GetDlgItem $0 $MUI_HWND 1203 SetCtlColors $0 "000000" "FFFFFF" ;设置控件背景为白白,文字为黑色 GetDlgItem $0 $MUI_HWND 1204 SetCtlColors $0 "000000" "FFFFFF" GetDlgItem $0 $MUI_HWND 1205 SetCtlColors $0 "000000" "FFFFFF" GetDlgItem $0 $MUI_HWND 1206 SetCtlColors $0 "000000" "FFFFFF" Pop $0 FunctionEnd /* Function leave ReadINIStr $R0 "$PLUGINSDIR\ioSpecial.ini" "Field 4" State ;读取控件的状态,这里是读取 StrCmp $R0 "1" 0 +2 Call instpre ReadINIStr $R0 "$PLUGINSDIR\ioSpecial.ini" "Field 5" State StrCmp $R0 "1" 0 +2 Call compre FunctionEnd */ Function compre ReadINIStr $R0 "$PLUGINSDIR\ioSpecial.ini" "Field 4" State ;读取控件的状态,这里是读取 ${If} $R0 == 1 Abort ${EndIf} FunctionEnd Function dirpre ReadINIStr $R0 "$PLUGINSDIR\ioSpecial.ini" "Field 4" State ;读取控件的状态,这里是读取 ${If} $R0 == 1 Abort ${EndIf} FunctionEnd Section "Main" SectionEnd