; NSIS 中自动替换背景图片的例子
!addincludedir .include
!addplugindir .plugins
;替换图片的时间间隔(ms)
!define TimeForChange 3000
;图片数量范围
!define MinBgImage 1 ;下限
!define MaxBgImage 2 ;上限
;图片名称变量
var iBgImage
; 安装程序初始定义常量
!define PRODUCT_NAME "My application"
!define PRODUCT_VERSION "1.0"
SetCompressor /SOLID lzma
!include "MUI2.nsh"
!include "nsWindows.nsh"
; MUI 预定义常量
;添加页面初始化函数
!define MUI_CUSTOMFUNCTION_GUIINIT MyGUIInit
; 欢迎页面
!insertmacro MUI_PAGE_WELCOME
; 安装目录选择页面
!insertmacro MUI_PAGE_DIRECTORY
; 安装过程页面
!insertmacro MUI_PAGE_INSTFILES
; 安装完成页面
!insertmacro MUI_PAGE_FINISH
; 安装界面包含的语言设置
!insertmacro MUI_LANGUAGE "SimpChinese"
; ------ MUI 现代界面定义结束 ------
Name "${PRODUCT_NAME} ${PRODUCT_VERSION}"
OutFile "Setup.exe"
InstallDir "$EXEDIR"
ShowInstDetails show
ShowUnInstDetails show
Section -
SectionEnd
Function .onInit
InitPluginsDir
;一次性释放所有的图片到临时目录中
StrCpy $iBgImage ${MinBgImage}
File "/oname=$PLUGINSDIR$iBgImage.bmp" ".images1.bmp"
Intop $iBgImage $iBgImage + 1
File "/oname=$PLUGINSDIR$iBgImage.bmp" ".images2.bmp"
FunctionEnd
Function MyGUIInit
;建立Timer
${NSW_Init} ;如果没有使用${NSW_CreateWindow}或者${NSW_CreateWindowEx},就必须用此宏初始化插件
${NSW_CreateTimer} OnTimer ${TimeForChange}
;设置初始背景
BgImage::SetBg /FILLSCREEN '$PLUGINSDIR${MaxBgImage}.bmp'
; BgImage::AddImage '$PLUGINSDIR${MaxBgImage}.bmp'
BgImage::Redraw
FunctionEnd
Function .onGUIEnd
BgImage::Destroy
FunctionEnd
Function OnTimer
${If} $iBgImage < ${MinBgImage}
StrCpy $iBgImage ${MinBgImage}
${ElseIf} $iBgImage >= ${MaxBgImage}
StrCpy $iBgImage ${MinBgImage}
${Else}
Intop $iBgImage $iBgImage + 1
${EndIf}
BgImage::Clear
BgImage::SetBg /FILLSCREEN '$PLUGINSDIR$iBgImage.bmp'
; BgImage::AddImage '$PLUGINSDIR$iBgImage.bmp'
BgImage::Redraw
FunctionEnd
© 版权声明
THE END
暂无评论内容