最新消息:

透明渐入渐出效果

nsis 永恒心锁 2243浏览 0评论
## transparent.nsi
##
## Script write by Restools & X-Star, Mod by zhfi.
## Needs the mod version of nsdialogs.dll or installoptions.dll plugin (suppert timer function)!
## Transparent Splash effect in NSIS while run/Exit installer, only effective on windows 2k or higher.
/*
## function usage:
;function SetLayeredWindowAttributes(hwnd: HWND; crKey: TColor; bAlpha: BYTE; dwFlags: DWORD): Boolean;
; external 'SetLayeredWindowAttributes@user32.dll stdcall';
;function GetWindowLong(Wnd: HWnd; Index: Integer): Longint;
; external 'GetWindowLongA@user32.dll stdcall';
;function SetWindowLong(Wnd: HWnd; Index: Integer; NewLong: Longint): Longint;
; external 'SetWindowLongA@user32.dll stdcall';
; SetWindowLong(WizardForm.Handle, GWL_EXSTYLE, GetWindowLong(WizardForm.Handle, GWL_EXSTYLE) or WS_EX_LAYERED);
system::call 'user32::GetWindowLong(i $HWNDPARENT, i ${GWL_EXSTYLE}) .iR0'
;messagebox mb_ok $R0
IntOp $R0 $R0 + ${WS_EX_LAYERED}
system::call 'user32::SetWindowLong(i $HWNDPARENT, i ${GWL_EXSTYLE}, i R0) .iR1'
; SetLayeredWindowAttributes(WizardForm.Handle, 0, Transparent, LWA_ALPHA);
system::call 'user32::SetLayeredWindowAttributes(i $HWNDPARENT, i 0, i $iTransparent, i ${LWA_ALPHA}) .iR2'
*/
!AddPluginDir .
;--------------------------------
;定义UI版本(MUI,MUI2)
!define MUI2
;定义透明度
!define iTransparentPercent 90
Var DIALOG
var iTransparent
var bTransparent
Name "Transparent Example"
SetCompressor /SOLID lzma
InstallDir $ExeDir
OutFile transparent_nsis.exe
!ifdef MUI2
!include MUI2.nsh
Var TIMERID
!else
!include MUI.nsh
;定义INI文件
!define INI $PLUGINSDIRtransparent.ini
!endif
!include LogicLib.nsh
!ifndef GWL_EXSTYLE
!define GWL_EXSTYLE -20
!endif
!ifndef WS_EX_LAYERED
!define WS_EX_LAYERED 0x80000
!endif
!ifndef LWA_ALPHA
!define LWA_ALPHA 2
!endif
!define MUI_CUSTOMFUNCTION_ABORT UserAbort
!ifdef MUI2
Page custom nsDialogsPage
!else
page custom InstallOptionsPage
!endif
!define MUI_PAGE_CUSTOMFUNCTION_SHOW welcome_PageShow
; 欢迎页面
!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_DIRECTORY
 !insertmacro MUI_PAGE_INSTFILES
 !insertmacro MUI_PAGE_FINISH
;--------------------------------
 !insertmacro MUI_LANGUAGE "SimpChinese"
Section -Nil
SectionEnd
Function welcome_PageShow
!ifdef MUI2
Pop $0
 nsDialogs::KillTimer /NOUNLOAD $TIMERID
!endif
 GetDlgItem $0 $hwndparent 3
 ShowWindow $0 0
 ${if} $bTransparent == 0
 ${For} $R0 0 $iTransparent
 system::call 'user32::SetLayeredWindowAttributes(i $HWNDPARENT, i 0, i R0, i ${LWA_ALPHA}) .iR1'
 sleep 1
 ${Next}
 ${endif}
 StrCpy $bTransparent 1
FunctionEnd
Function Exit
 ${ForEach} $R0 $iTransparent 0 - 1
 system::call 'user32::SetLayeredWindowAttributes(i $HWNDPARENT, i 0, i R0, i ${LWA_ALPHA}) .iR1'
 sleep 1
 ${Next}
FunctionEnd
Function UserAbort
 Messagebox MB_YESNO|MB_ICONQUESTION "Are Sure you want to cancel?" IDYES +2
 Abort
 call Exit
FunctionEnd
Function .onInstSuccess
 Messagebox MB_OK|MB_ICONINFORMATION "Install Success!"
 call Exit
FunctionEnd
Function SetWindowAttrib
 ${if} $bTransparent == 0
 system::call 'user32::GetWindowLong(i $HWNDPARENT, i ${GWL_EXSTYLE}) .iR0'
 ;messagebox mb_ok $R0
 IntOp $R0 $R0 + ${WS_EX_LAYERED}
 system::call 'user32::SetWindowLong(i $HWNDPARENT, i ${GWL_EXSTYLE}, i R0) .iR1'
 system::call 'user32::SetLayeredWindowAttributes(i $HWNDPARENT, i 0, i 0, i ${LWA_ALPHA}) .iR2'
 Pop $R2
 Pop $R1
 Pop $R0
 ${endif}
FunctionEnd
!ifndef MUI2
Function InstallOptionsPage
 Call SetWindowAttrib
 InstallOptions::initDialog /NOUNLOAD ${INI}
 Pop $DIALOG
;如果你想做的更逼真一些,请把它仿成欢迎页面(你的初始页面)一样的
 InstallOptions::Show
FunctionEnd
!endif
!ifdef MUI2
Function OnTimer
Pop $0 ;Free Timer id
 GetDlgItem $1 $HWNDPARENT 1
 SendMessage $1 ${BM_CLICK} 0 1
FunctionEnd
Function nsDialogsPage
 Call SetWindowAttrib
nsDialogs::Create /NOUNLOAD 1018
Pop $DIALOG
;如果你想做的更逼真一些,请把它仿成欢迎页面(你的初始页面)一样的
GetFunctionAddress $0 OnTimer
nsDialogs::CreateTimer /NOUNLOAD $0 10
Pop $TIMERID
nsDialogs::Show
FunctionEnd
!endif
Function .OnInit
 InitPluginsDir
!ifndef MUI2
 File /oname=${INI} "transparent.ini"
!endif
 IntOp $iTransparent ${iTransparentPercent} * 255
 IntOp $iTransparent $iTransparent / 100
 StrCpy $bTransparent 0
FunctionEnd
免责声明:根据《计算机软件保护条例》第十七条规定“为了学习和研究软件内含的设计思想和原理,通过安装、显示、传输或者存储软件等方式使用软件的,可以不经软件著作权人许可,不向其支付报酬。”您需知晓本站所有内容资源均来源于网络,仅供用户交流学习与研究使用,版权归属原版权方所有,版权争议与本站无关,用户本人下载后不能用作商业或非法用途,需在24个小时之内从您的电脑中彻底删除上述内容,否则后果均由用户承担责任;如果您访问和下载此文件,表示您同意只将此文件用于参考、学习而非其他用途,否则一切后果请您自行承担,如果您喜欢该程序,请支持正版软件,购买注册,得到更好的正版服务。丨本站为个人博客非盈利性站点,所有软件信息均来自网络,所有资源仅供学习参考研究目的,并不贩卖软件,不存在任何商业目的及用途。丨本文采用知识共享 署名4.0国际许可协议 [BY-NC-SA] 进行授权BY-NC-SA协议进行授权

转载请注明:永恒心锁-分享互联网 » 透明渐入渐出效果

发表我的评论
取消评论
表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址