安静
PHP技术博客

在欢迎界面添加安装方式的选择

之前有位朋友问我如何实现下面的界面效果,我借鉴了一下ansifa的方法,完成界面上控件的初步实现,如下图效果:

分享代码如下:

SetCompressor /SOLID lzma
SetCompressorDictSize 32
XPStyle on
Name “Welcome_setuptype”
OutFile “Welcome_setuptype.exe”
!include “MUI.nsh”
;页面自定义函数
!define MUI_PAGE_CUSTOMFUNCTION_PRE Pre
!define MUI_PAGE_CUSTOMFUNCTION_SHOW Show
!define MUI_PAGE_CUSTOMFUNCTION_LEAVE leave
; 欢迎页面
!insertmacro MUI_PAGE_WELCOME
;选择安装方式” “请选择软件的安装方式。”
!insertmacro MUI_PAGE_COMPONENTS
; 安装目录选择页面
!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
MessageBox MB_OK “标准安装(推荐)”
ReadINIStr $R0 “$PLUGINSDIR\ioSpecial.ini” “Field 5” State
StrCmp $R0 “1” 0 +2
MessageBox MB_OK “自定义安装”
FunctionEnd
Section “-Dreams8”
SectionEnd
赞(0) 打赏
未经允许不得转载:AJ's Blog » 在欢迎界面添加安装方式的选择
分享到: 更多 (0)

评论 3

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
  1. #-49

    -_- welcome man~
    新的博主 枫叶 软件测试经理

    可 乐烟11年前 (2010-08-18)
  2. #-48

    晕,也不用报职位吧~~哈哈

    枫 叶11年前 (2010-08-18)
  3. #-47

    职位报出来好 -_-说不定以后还能在这里遇到一些你的同行业人事

    可 乐烟11年前 (2010-08-18)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏