Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Reply
Thread Tools Search this Thread Display Modes
Old 17th April 2019, 11:44   #1
meoit
Member
 
Join Date: Oct 2014
Location: $DESKTOP
Posts: 90
Post How to remember checkbox state when the Back button clicked

Hi all.

My Installer have 3 checkboxs.

Checkbox1 belong to Page1
Checkbox2 belong to Page2
Checkbox3 belong to Page2

How to remember Checkbox2 and Checkbox3 state when the Back button clicked (back from page2 to page1) ?.

This is code:

code:

Var /GLOBAL CheckBox1
Var /GLOBAL CheckBox1_State
Var /GLOBAL CheckBox2
Var /GLOBAL CheckBox2_State
Var /GLOBAL CheckBox3
Var /GLOBAL CheckBox3_State

!include MUI2.nsh

Page custom Page1_Show
Page custom Page2_Show Page2_Leave
Page custom Page3_Show
!insertmacro MUI_PAGE_INSTFILES

!insertmacro MUI_LANGUAGE English

Section 'A'
SectionEnd

Function .onInit
StrCpy $CheckBox2_State ${BST_CHECKED} ; Set initial/default state
StrCpy $CheckBox3_State ${BST_UNCHECKED} ; Set initial/default state
FunctionEnd

Function Page1_Show
Call Page1_Create
GD::Show
FunctionEnd

Function Page2_Show
Call Page2_Create
GD::Show
FunctionEnd

Function Page3_Show
Call Page3_Create
GD::Show
FunctionEnd

Function Page2_Leave
${NSD_GetState} $CheckBox2 $CheckBox2_State
${NSD_GetState} $CheckBox3 $CheckBox3_State
FunctionEnd

!macro PAGE1
Function Page1_Create
GetDlgItem $R0 $HWNDPARENT 1 #next/install button
EnableWindow $R0 0
GD::Create 1044
Pop $1
${If} $1 == error
Abort
${EndIf}
${NSD_CreateCheckbox} 105.32u 100u 217.22u 10.77u 'CheckBox1'
Pop $CheckBox1
${NSD_OnClick} $CheckBox1 CheckBox1_Click
FunctionEnd
Function CheckBox1_Click
${NSD_GetState} $CheckBox1 $CheckBox1_State
${If} $CheckBox1_State == ${BST_CHECKED}
GetDlgItem $R0 $HWNDPARENT 1
EnableWindow $R0 1
${Else}
GetDlgItem $R0 $HWNDPARENT 1
EnableWindow $R0 0
${EndIf}
FunctionEnd
!macroend
!insertmacro PAGE1

!macro PAGE2
Function Page2_Create
GD::Create 1044
Pop $1
${If} $1 == error
Abort
${EndIf}
${NSD_CreateCheckbox} 106.63u 62u 217.22u 14.77u 'CheckBox2'
Pop $CheckBox2
${NSD_SetState} $CheckBox2 $CheckBox2_State
${NSD_CreateCheckbox} 106.63u 74u 217.22u 14.77u 'CheckBox3'
Pop $CheckBox3
${NSD_SetState} $CheckBox3 $CheckBox3_State
FunctionEnd
!macroend
!insertmacro PAGE2

!macro PAGE3
Function Page3_Create
GD::Create 1044
Pop $1
${If} $1 == error
Abort
${EndIf}
FunctionEnd
!macroend
!insertmacro PAGE3

meoit is offline   Reply With Quote
Old 17th April 2019, 17:41   #2
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,100
You don't generally save state when the user presses Back, only Next. I don't know what the GD plug-in is but the nsDialogs plug-in let's you hook the Back button if you really want to.

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 17th April 2019, 18:43   #3
r2du-soft
Senior Member
 
r2du-soft's Avatar
 
Join Date: Nov 2013
Location: Iran
Posts: 334
Try this:

HTML Code:
Var /GLOBAL CheckBox1

Var /GLOBAL CheckBox1_State

Var /GLOBAL CheckBox2

Var /GLOBAL CheckBox2_State

Var /GLOBAL CheckBox3

Var /GLOBAL CheckBox3_State



!include MUI2.nsh



Page custom Page1_Show

Page custom Page2_Show Page2_Leave

Page custom Page3_Show

!insertmacro MUI_PAGE_INSTFILES



!insertmacro MUI_LANGUAGE English



Section 'A'

SectionEnd



Function .onInit

	StrCpy $CheckBox2_State ${BST_CHECKED} ; Set initial/default state

	StrCpy $CheckBox3_State ${BST_UNCHECKED} ; Set initial/default state

FunctionEnd



Function Page1_Show

	Call Page1_Create

	nsDialogs::Show

FunctionEnd



Function Page2_Show

	Call Page2_Create
	
	nsDialogs::Show

FunctionEnd



Function Page3_Show

	Call Page3_Create
	
	nsDialogs::Show

FunctionEnd



Function Page2_Leave

	${NSD_GetState} $CheckBox2 $CheckBox2_State
	${NSD_GetState} $CheckBox3 $CheckBox3_State

FunctionEnd



!macro PAGE1

	Function Page1_Create

		GetDlgItem $R0 $HWNDPARENT 1 #next/install button

		EnableWindow $R0 0

		nsDialogs::Create 1044

		Pop $1

		${If} $1 == error

			Abort

		${EndIf}

		${NSD_CreateCheckbox} 105.32u 100u 217.22u 10.77u 'CheckBox1'

		Pop $CheckBox1

		${NSD_OnClick} $CheckBox1 CheckBox1_Click

	FunctionEnd

	Function CheckBox1_Click

		Pop $0
		${NSD_GetState} $CheckBox1 $CheckBox1_State

		${If} $CheckBox1_State == ${BST_CHECKED}

			GetDlgItem $R0 $HWNDPARENT 1

			EnableWindow $R0 1

		${Else}

			GetDlgItem $R0 $HWNDPARENT 1

			EnableWindow $R0 0

		${EndIf}

	FunctionEnd

!macroend

!insertmacro PAGE1



!macro PAGE2

	Function Page2_Create

		nsDialogs::Create 1044

		Pop $1

		${If} $1 == error

			Abort

		${EndIf}

		${NSD_CreateCheckbox} 106.63u 62u 217.22u 14.77u 'CheckBox2'

		Pop $CheckBox2

		${NSD_SetState} $CheckBox2 $CheckBox2_State
		
		${NSD_OnClick} $CheckBox2 CheckBox2_Click

		${NSD_CreateCheckbox} 106.63u 74u 217.22u 14.77u 'CheckBox3'

		Pop $CheckBox3

		${NSD_SetState} $CheckBox3 $CheckBox3_State
		
		${NSD_OnClick} $CheckBox3 CheckBox3_Click

	FunctionEnd
	
	
	Function CheckBox2_Click
	
		Pop $0
		${NSD_GetState} $CheckBox2 $CheckBox2_State

	FunctionEnd
	
	
	
	Function CheckBox3_Click
	
		Pop $0
		${NSD_GetState} $CheckBox3 $CheckBox3_State

	FunctionEnd
	

!macroend

!insertmacro PAGE2



!macro PAGE3

	Function Page3_Create

		nsDialogs::Create 1044

		Pop $1

		${If} $1 == error

			Abort

		${EndIf}

	FunctionEnd

!macroend

!insertmacro PAGE3
r2du-soft is offline   Reply With Quote
Old 20th April 2019, 13:32   #4
meoit
Member
 
Join Date: Oct 2014
Location: $DESKTOP
Posts: 90
Thanks r2du-soft.

The code is working fine.
meoit is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump