NsDialogs FAQ

From NSIS Wiki
Revision as of 21:45, 13 February 2009 by ZeBoxx (talk | contribs) (New page: == How to Enable/Disable a control == A. Use the standard NSIS EnableWindow command. NSDialogs lets you pop the hwnd of a control created via ${NSD_Create*}. EnableWindow takes a hwnd as...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

How to Enable/Disable a control

A. Use the standard NSIS EnableWindow command.

NSDialogs lets you pop the hwnd of a control created via ${NSD_Create*}. EnableWindow takes a hwnd as one of its parameters. With this, you can easily enable/disable a control.

!include "nsDialogs.nsh"
!include "winmessages.nsh"
!include "logiclib.nsh"
OutFile "test.exe"
 
Page Custom pre
 
var dialog
var hwnd
var button
 
Function pre
	nsDialogs::Create 1018
	Pop $dialog
	${NSD_CreateCheckbox} 0 0 50% 6% "Enable button below"
		Pop $hwnd
		${NSD_OnClick} $hwnd EnDisableButton
 
	${NSD_CreateButton} 25% 25% 50% 50% "Hello World"
		Pop $button
		EnableWindow $button 0 # start out disabled
		nsDialogs::Show
FunctionEnd
 
Function EnDisableButton
	Pop $hwnd
	${NSD_GetState} $hwnd $0
	${If} $0 == 1
		EnableWindow $button 1
	${Else}
		EnableWindow $button 0
	${EndIf}
FunctionEnd
 
Section ""
SectionEnd