最新消息:

透明渐入渐出效果

nsis 永恒心锁 1554浏览 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
永恒心锁,版权所有丨如未注明,均为转载丨本网站采用BY-NC-SA协议进行授权

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

您必须 登录 才能发表评论!