;NSDialogs 允许使用 ${NSD_Create*} 创建控件并返回 HWND 值到堆栈,这样我们很方便就可以对控件进行设置可用或不可用,当然我们这里要使用NSIS里的ShowWindow 命令。
!include "nsDialogs.nsh"
!include "winmessages.nsh"
!include "logiclib.nsh"
Caption "如何使控件显示或隐藏"
OutFile "yhxs3344.exe"
loadlanguagefile "${NSISDIR}ContribLanguage filessimpChinese.nlf"
Page Custom pre
var dialog
var hwnd
var button
Function pre
nsDialogs::Create 1018
Pop $dialog
${NSD_CreateCheckbox} 0 0 50% 6% "显示/隐藏按钮"
Pop $hwnd
${NSD_OnClick} $hwnd EnDisableButton
${NSD_CreateButton} 25% 25% 50% 50% "永恒心锁"
Pop $button
ShowWindow $button ${SW_HIDE} # 开始状态为隐藏 SW_HIDE
nsDialogs::Show
FunctionEnd
Function EnDisableButton
Pop $hwnd
${NSD_GetState} $hwnd $0
${If} $0 == 1
ShowWindow $button ${SW_SHOW}
${Else}
ShowWindow $button ${SW_HIDE}
${EndIf}
FunctionEnd
Section ""
SectionEnd
!include "nsDialogs.nsh"
!include "winmessages.nsh"
!include "logiclib.nsh"
Caption "如何使控件显示或隐藏"
OutFile "yhxs3344.exe"
loadlanguagefile "${NSISDIR}ContribLanguage filessimpChinese.nlf"
Page Custom pre
var dialog
var hwnd
var button
Function pre
nsDialogs::Create 1018
Pop $dialog
${NSD_CreateCheckbox} 0 0 50% 6% "显示/隐藏按钮"
Pop $hwnd
${NSD_OnClick} $hwnd EnDisableButton
${NSD_CreateButton} 25% 25% 50% 50% "永恒心锁"
Pop $button
${NSD_OnClick} $button OpenURL
ShowWindow $button ${SW_HIDE} # 开始状态为隐藏 SW_HIDE
nsDialogs::Show
FunctionEnd
Function EnDisableButton
Pop $hwnd
${NSD_GetState} $hwnd $0
${If} $0 == 1
ShowWindow $button ${SW_SHOW}
${Else}
ShowWindow $button ${SW_HIDE}
${EndIf}
FunctionEnd
Function OpenURL
Pop $button
ExecShell open "http://www.yhxs3344.net"
FunctionEnd
Section ""
SectionEnd
THE END
暂无评论内容