nsDialogs如何使控件显示或隐藏

;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
喜欢就支持一下吧
点赞14 分享
评论 抢沙发

请登录后发表评论

    暂无评论内容