NSIS:如何删除nsDialogs中可用的Label或任何其他控件?

时间:2018-01-29 06:34:16

标签: nsis

方案: 我有一个使用$ {NSD_CreateCheckBox}创建的复选框。使用http://nsis.sourceforge.net/Docs/nsDialogs/Readme.html#step-notify给出的方法,对于$ {NSD_OnClick},我使用$ {NSD_CreateLabel}创建一个Label,每当检查标记时都会在checkBox下面。

现在,当我取消选中checkBox控件时,如何删除CheckBox下面创建的Label。

是否有$ {NSD_Delete *}?

1 个答案:

答案 0 :(得分:1)

没有删除宏,但如果你确实需要它,你可以实现自己的宏,但通常你只是显示/隐藏一个控件。

!include nsDialogs.nsh
!include LogicLib.nsh

!ifndef NSD_DestroyControl
!define NSD_DestroyControl "!insertmacro NSD_DestroyControl "
!macro NSD_DestroyControl h
System::Call 'USER32::DestroyWindow(i${h})'
#Could also use: SendMessage ${h} ${WM_CLOSE} 0 0
!macroend
!endif

Page Custom MyPage
Page InstFiles

Var CheckShowHide
Var Lbl1
Var CheckDestroy
Var Lbl2

Function MyPage
nsDialogs::Create 1018
Pop $0

${NSD_CreateCheckbox} 0 30u 100% 10u "Show/Hide"
Pop $CheckShowHide
${NSD_CreateLabel} 0 50u 100% 12u "Hello"
Pop $Lbl1
${NSD_OnClick} $CheckShowHide ShowHide
${NSD_Check} $CheckShowHide

${NSD_CreateCheckbox} 0 70u 100% 10u "Create/Destroy"
Pop $CheckDestroy
${NSD_OnClick} $CheckDestroy CreateDestroy

nsDialogs::Show
FunctionEnd

Function ShowHide
Pop $0
${NSD_GetState} $CheckShowHide $0
${If} $0 = ${BST_UNCHECKED}
  ShowWindow $Lbl1 0
${Else}
  ShowWindow $Lbl1 1
${EndIF}
FunctionEnd

Function CreateDestroy
Pop $0
${NSD_GetState} $CheckDestroy $0
${If} $0 = ${BST_UNCHECKED}
  ${NSD_DestroyControl} $Lbl2
${Else}
  ${NSD_CreateLabel} 0 90u 100% 12u "World"
  Pop $Lbl2
${EndIF}
FunctionEnd