Skip to content
⌘ NSIS Forum Archive

Checkboxes in "PageEx directory"

9 posts

w000t#

Checkboxes in "PageEx directory"

Hey guy,

how do I make something like this


Var /GLOBAL INSTALL_DIR
Var /GLOBAL CHECKBOX

PageEx directory
Caption ': Installationsverzeichnis'
DirText "text here" "" "" "text here"
DirVar $INSTALL_DIR
${NSD_CreateCheckbox} 0 -50 100% 8u Test
Pop $CHECKBOX
PageExEnd
I included this file in my installer but it won't work.
While this does:


Var /GLOBAL INSTALL_DIR

PageEx directory
Caption ': Installationsverzeichnis'
DirText "text here" "" "" "text here"
PageExEnd
Anders#
NSD_* macros only work on custom pages that use the nsDialogs plugin, if you want to change the standard dialogs you must use Resource Hacker and the ChangeUI instruction...
w000t#
Originally Posted by Anders View Post
NSD_* macros only work on custom pages that use the nsDialogs plugin, if you want to change the standard dialogs you must use Resource Hacker and the ChangeUI instruction...
Is there any other way?
We remcompile the Installer pretty often, so it would be no so good to use ResHacker every time.

The thing I want is a page that looks like the standard page but with a checkbox.
(I want the checkbox to provide "Advanced settings")

________________________________________________________
Edit: Okay if this doesn't work, here is an other question.

If my checkbox is not checked, then I want to skip the next 2 pages.

Originally Posted by checkbox.nsi

Var /GLOBAL CHECKBOX
Var /GLOBAL ADVANCEDMODE
Function nsDialogsPage

nsDialogs::Create 1018
Pop $0

${NSD_CreateCheckbox} 60% -50 100% 8u "Advanced settings"
Pop $CHECKBOX
GetFunctionAddress $0 OnCheckbox
nsDialogs::OnClick $CHECKBOX $0
nsDialogs::Show

FunctionEnd

Function OnCheckbox
Pop $0
StrCpy $ADVANCEDMODE $0
MessageBox MB_OK "Checkbox clicked!!!"
FunctionEnd
And the relevant part of the other file looks like this:

Originally Posted by installer.nsi

!include checkbox.nsi
Page custom nsDialogsPage
!include install-dir-selection-page.nsi
${If} $ADVANCEDMODE == "0"
!include chrome-selection-page.nsi
!include java-selection-page.nsi
${Endif}
Whats wrong with it?
Anders#
You only use Resource Hacker once on a file in \NSIS\Contrib\UIs and save as a new .exe that you give to ChangeUI in the script.

To skip a page you must call Abort in the pre-callback for that page...
w000t#
Originally Posted by Anders View Post
To skip a page you must call Abort in the pre-callback for that page...
But how I can I do this with included files? (I am sorry, I am little bit confused too much NSIS for today I guess)

Edit:

I just wrote this in my "java-selection-page.nsi"file and it seems not the work

PageEx directory
${If} $ADVANCEDMODE == 0
Abort
${EndIf}
Othercodeishere
PageExEnd
JasonFriday13#
Originally Posted by w000t View Post
But how I can I do this with included files? (I am sorry, I am little bit confused too much NSIS for today I guess)

Edit:

I just wrote this in my "java-selection-page.nsi"file and it seems not the work
PageEx directory
${If} $ADVANCEDMODE == 0
Abort
${EndIf}
Othercodeishere
PageExEnd
Like Anders said, it has to be in a callback function:
Originally Posted by callback_skip.nsi
Name "callback_skip"
OutFile "callback_skip.exe"

PageEx Directory
PageCallbacks DirectoryPre DirectoryLeave
PageExEnd
Page Components
Page InstFiles

Function DirectoryPre
Abort
FunctionEnd

Function DirectoryLeave
FunctionEnd

Section
SectionEnd
Also, this is wrong:
!include checkbox.nsi
Page custom nsDialogsPage
!include install-dir-selection-page.nsi
${If} $ADVANCEDMODE == "0"
!include chrome-selection-page.nsi
!include java-selection-page.nsi
${Endif}
You're mixing compile time commands with run time commands. At compile time, all pages must be included, and at run time you can skip pages or do other stuff that's required.

This (http://nsis.sourceforge.net/NonObligatoricPages) is also a good example for run time commands and page skipping.
w000t#
Thank you very much your your answers, it works pretty good so far.

Just one more question, if I check my checkbox then press "Next" and then "Back" then my checkbox doesnt show as checked.
I see where the problem ist, but I dont know how to fix it.

Function nsDialogsPage

nsDialogs::Create 1018
Pop $0
${NSD_CreateLabel} 10% 10% 70% 40u "test"
${NSD_CreateCheckbox} 60% -50 100% 8u "test2"
Pop $CHECKBOX
GetFunctionAddress $0 OnCheckbox
nsDialogs::OnClick $CHECKBOX $0
Pop $0
nsDialogs::Show

FunctionEnd

Function OnCheckbox
Pop $0
StrCpy $ADVANCEDMODE $0
FunctionEnd
Anders#
You normally don't use OnClick on a checkbox, you just get the state in the page leave callback function with NSD_GetState. When you create the page you need to use NSD_SetState so back works correctly...