技术vs艺术

技术是扎实的基本功,艺术是丰富的想象力;技术的突破总是从夸张的想像中开始的。

博客园 首页 新随笔 联系 订阅 管理

http://restools.hanzify.org/article.asp?id=39

以前有一个例子是一个在 .onSelChange 中实现实时设定是否显示下一个自定义页面的方法。http://restools.hanzify.org/article.asp?id=26
但是这种方法需要定义一个变量,而且需要每次点击“组件”的时候都会触发事件,显得过于累赘。下面这个例子是在下一个页面的初始化时检测组件选择,从而达到是否显示自定义页面的效果。

 

/*---------------------------------------
自定义页面结合组件选择安装测试简单脚本。
-----------------------------------------*/

!include "MUI.nsh"
!include "Sections.nsh"

Name "自定义页面结合组件选择测试"
OutFile "Setup.exe"

!insertmacro MUI_PAGE_COMPONENTS
Page custom PageInitFunc PageLeaveFunc ""  # 自定义页面
!insertmacro MUI_PAGE_INSTFILES

!insertmacro MUI_LANGUAGE "SimpChinese"  # 设置安装界面语言

ShowInstDetails show # 显示安装进度信息

ReserveFile "io.ini" # 预先打包文件,方便安装加速释放 io.ini
!insertmacro MUI_RESERVEFILE_INSTALLOPTIONS  # 预先打包文件,方便安装加速释放

Function .onInit
  !insertmacro MUI_INSTALLOPTIONS_EXTRACT "io.ini"  # 初始化页面
FunctionEnd

Function
PageInitFunc
  SectionGetFlags ${SEC1} $0  # 检测 SEC1 的选择状态,1为已勾选该组件
  
IntOp $0 $0 & ${SF_selectED} # 只过滤勾选的状态,Checkbox 的状态可能包含多位
  
IntCmp $0 ${SF_selectED} showpage hidepage hidepage
  showpage:
  !insertmacro MUI_INSTALLOPTIONS_DISPLAY "io.ini"  # 显示页面
  
hidepage:
FunctionEnd

Function
PageLeaveFunc
  MessageBox MB_OK "自定义页面离开时操作,即点击下一步后触发的事件"
FunctionEnd

Section
"数据库处理(自定义页面)" SEC1
  # 所有数据库处理在这里写
  
MessageBox MB_OK "“数据库处理(自定义页面)”操作内容"
SectionEnd

Section
"其他操作" SEC2
# 这里填写其他组件的操作
  
MessageBox MB_OK "“其他操作”操作内容"
SectionEnd

 

 

 

[Settings]
NumFields=7

[Field 1]
Type=label
Text=SQLServer 连接
Left=0
Right=-1
Top=0
Bottom=9

[Field 2]
Type=Text
Left=40
Right=163
Top=22
Bottom=35

[Field 3]
Type=Text
Left=39
Right=163
Top=43
Bottom=54

[Field 4]
Type=Password
Left=39
Right=163
Top=62
Bottom=75

[Field 5]
Type=Label
Text=密码:
Left=8
Right=36
Top=65
Bottom=75

[Field 6]
Type=Label
Text=账号:
Left=8
Right=38
Top=46
Bottom=56

[Field 7]
Type=Label
Text=服务器:
Left=6
Right=34
Top=27
Bottom=36

 

posted on 2009-11-26 18:40  邓春光  阅读(3352)  评论(0编辑  收藏  举报