NsDialogs FAQ: Difference between revisions

From NSIS Wiki
Jump to navigationJump to search
(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...)
 
No edit summary
Line 35: Line 35:
${Else}
${Else}
EnableWindow $button 0
EnableWindow $button 0
${EndIf}
FunctionEnd
Section ""
SectionEnd
</highlight-nsis>
== How to Show/Hide a control ==
A. Use the standard NSIS ShowWindow command.
NSDialogs lets you pop the hwnd of a control created via ${NSD_Create*}.  ShowWindow takes a hwnd as one of its parameters.  With this, you can easily show/hide a control.
<highlight-nsis>
!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% "Show button below"
Pop $hwnd
${NSD_OnClick} $hwnd EnDisableButton
${NSD_CreateButton} 25% 25% 50% 50% "Hello World"
Pop $button
ShowWindow $button ${SW_HIDE} # start out hidden
nsDialogs::Show
FunctionEnd
Function EnDisableButton
Pop $hwnd
${NSD_GetState} $hwnd $0
${If} $0 == 1
ShowWindow $button ${SW_SHOW}
${Else}
ShowWindow $button ${SW_HIDE}
${EndIf}
${EndIf}
FunctionEnd
FunctionEnd

Revision as of 21:47, 13 February 2009

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

How to Show/Hide a control

A. Use the standard NSIS ShowWindow command.

NSDialogs lets you pop the hwnd of a control created via ${NSD_Create*}. ShowWindow takes a hwnd as one of its parameters. With this, you can easily show/hide 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% "Show button below"
		Pop $hwnd
		${NSD_OnClick} $hwnd EnDisableButton
 
	${NSD_CreateButton} 25% 25% 50% 50% "Hello World"
		Pop $button
		ShowWindow $button ${SW_HIDE} # start out hidden
		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