Archive: A better integration of InstallOptions


A better integration of InstallOptions
Hi again,

Playing more with InstallOptions, i got the idea that having it running in between some dialog pages of NSIS would be better than running it int some install section. So here is my (very small) hack for NSIS1.65 (attached as unified diff) which adds the following new feature:

You now can declare a Function named .onDlgPage which gets called whenever the user switches to the next (or previous) page of the installer. Before calling this function, NSIS pushes 2 integers, previous_page_nr and new_page_nr on the stack which of course have to be popped within that function. The first dialog page (copyright) is 0, and so on. When the installer displays the first time, previous_page_nr is -1.

Having this new feature, i now can use the following script snippet to "hook" an additional dialog in between the component selection page and the installdir selection page (just as an example):


Function .onDlgPage
exch $0
exch
exch $1
; MessageBox MB_OK ".onDlgPage called, arg0=$0, arg1=$1"
IntCmp $0 1 0 nomatch nomatch
IntCmp $1 2 0 nomatch nomatch
call SelectProgramGroup
nomatch:
pop $1
pop $0
FunctionEnd

Function SelectProgramGroup
push $OUTDIR
SetOutPath $TEMP
File /oname=browsegroup.ini browsegroup.txt
File InstallOptions.exe
WriteINIStr "$TEMP\browsegroup.ini" Settings ParentWnd $HWNDPARENT
WriteINIStr "$TEMP\browsegroup.ini" "Field 1" Text "$SMPROGRAMS"
ExecWait "$TEMP\InstallOptions $TEMP\browsegroup.ini"
pop $OUTDIR
ReadINIStr $9 $TEMP\browsegroup.ini Results 1
;MessageBox MB_OK "IO finished, returned $9"
FunctionEnd


The (currently very poor) browsegroup.txt looks like this:


[Settings]
Title="Program group"
Caption="Select a group to install shortcuts in."
ParentWnd=0
NumFields=1

[Field 1]
Type=DirRequest
Text=
MaxLen=1024
MinLen=2
Left=20
Top=60
Right=400
Bottom=85


BTW:
In the NSIS1.65 source distribution, some library settings for
Debug are missing: For makenssi, add version.lib and for exehead, add
comctl32.lib

Ciao
-Fritz

Re: A better integration of InstallOptions
... have to quote myself:

Originally posted by felfert
[B]Hi again,

Playing more with InstallOptions, ....
How to apply this patch:

1. You need the "patch" program for that.
1a. Get cygwin at http://sources.redhat.com/cygwin/
or
1b. put the source-tree and the patch on a Linux-Box

2. cd into the toplevel Source direcory
3. Unzip the zipfile there
4. run patch -p1 < nsis1.65-onDlgPage.patch

Ciao
-Fritz