Archive: Custom finish page with iospecial.ini problem


Custom finish page with iospecial.ini problem
Hello,
I'm quite new to creeating custom finish page in NSIS installer and have a problem. The goal is to create three checkboxes on the finicsh page. I use NSIS MUI, so two checkboxes -- no problem (MUI_FINISHPAGE_RUN etc.). But three checkboxes requires custom page function. I've researched that I should write into iospecial.ini file in order to customize the finish page. But I'm not able to write there! I'm trying something like this:

; ...
!define MUI_PAGE_CUSTOMFUNCTION_PRE FinishPre
!define MUI_PAGE_CUSTOMFUNCTION_LEAVE FinishLeave
; ...
!insertmacro MUI_PAGE_FINISH
; ...
Function FinishPre
WriteINIStr "$PLUGINSDIR\iospecial.ini" "Settings" "NumFields" "4"
WriteINIStr "$PLUGINSDIR\iospecial.ini" "Field 4" "Type" "CheckBox"
WriteINIStr "$PLUGINSDIR\iospecial.ini" "Field 4" "Text" "&Create Quicklaunch Shortcut"
WriteINIStr "$PLUGINSDIR\iospecial.ini" "Field 4" "Left" "120"
WriteINIStr "$PLUGINSDIR\iospecial.ini" "Field 4" "Right" "315"
WriteINIStr "$PLUGINSDIR\iospecial.ini" "Field 4" "Top" "130"
WriteINIStr "$PLUGINSDIR\iospecial.ini" "Field 4" "Bottom" "140"
WriteINIStr "$PLUGINSDIR\iospecial.ini" "Field 4" "State" "1"
FunctionEnd

Function FinishLeave
ReadINIStr $0 "iospecial.ini" "Settings" "NumFields"
MessageBox MB_OK "FinishLeave function: $0"
FunctionEnd

But it does nothing... Beterr to say, message box appears, functions called, but writing into ini file seems doesn't work.

I appreciate any ideas, if you have... Thanks in advance!


I assume you have put

!define MUI_PAGE_CUSTOMFUNCTION_PRE FinishPre
!define MUI_PAGE_CUSTOMFUNCTION_LEAVE FinishLeave
just before
!insertmacro MUI_PAGE_FINISH
, and nothing in between?

Stu

It is part of bigger and more complex installer, so I posted only lines relevant for my problem. There is something between, of course. But all related to this I've posted above, I hope. Is there something missing? Maybe it is the problem...


You should !define the pre and leave functions immediately before you !insertmacro the finish page. Don't put anything in between.


Yes, I have now this piece of code (nothing between !define pre and leave function and !insertmacto finish page):

Function FinishPre
MessageBox MB_OK "FinishPre function"
WriteINIStr "$PLUGINSDIR\iospecial.ini" "Settings" "NumFields" "6"
WriteINIStr "$PLUGINSDIR\iospecial.ini" "Field 6" "Type" "Label"
WriteINIStr "$PLUGINSDIR\iospecial.ini" "Field 6" "Text" "blah"
WriteINIStr "$PLUGINSDIR\iospecial.ini" "Field 6" "Left" "200"
WriteINIStr "$PLUGINSDIR\iospecial.ini" "Field 6" "Right" "250"
WriteINIStr "$PLUGINSDIR\iospecial.ini" "Field 6" "Top" "100"
WriteINIStr "$PLUGINSDIR\iospecial.ini" "Field 6" "Bottom" "120"
FunctionEnd

Function FinishLeave
Push $0
MessageBox MB_OK "FinishLeave function"
ReadINIStr $0 "$PLUGINSDIR\iospecial.ini" "Field 6" "Text"
MessageBox MB_OK "field 6 text: $0"
Pop $0
FunctionEnd

!define MUI_PAGE_CUSTOMFUNCTION_PRE FinishPre
!define MUI_PAGE_CUSTOMFUNCTION_LEAVE FinishLeave
!insertmacro MUI_PAGE_FINISH


But it does nothing! In the leave function, my text 'blah' is red and also displayed in the messagebox, it's ok, but no label, nothing displayed on the finish page! (better to say, there is something, but no my label with text "blah")

I was looking for the file iospecial.ini in the $PLUGINSDIR, but there is no iospecial.ini file. Could it be the problem?

Another thing -- I don't know which field number can I use -- is the field number important? It seems that iospecial.ini file which I write into is something different that iospecial.ini used by NSIS to create finish page...

If there's no iospecial.ini you're not looking properly, because you just said yourself that 'blah' is read from iospecial.ini without problems.

Also, note that you should be using MUI1, not MUI2.


Yes, text 'blah' is read in leave function, but not displayed on finish page, i.e. not used -- so I think I'm writing into some different iospecial.ini... Or any other thing?
I was looking for iospecial.ini in the $PLUGINSDIR, i.e. in the temporary directory during installer is running.

I include "MUI2.nsh".


If you use MUI2 you need to be using nsDialogs not InstallOptions.

Stu


So does it mean that MUI2 with InstallOptions sometimes works and sometimes not?
I'm not author of whole this installer so I don't know some things, but InstallOptions worked well till now.


No the point is MUI2 uses nsDialogs for its finish/welcome pages. Therefore there is no ioSpecial.ini. If you want to add to the finish/welcome pages, use nsDialogs.

Stu


So I've tried to add something to the finish page but not succesful again..

Var Label

Function FinishPre
${NSD_CreateLabel} 50 50 100% 12u "blah blah"
Pop $Label
FunctionEnd

Function FinishLeave
# ...
FunctionEnd

!define MUI_PAGE_CUSTOMFUNCTION_PRE FinishPre
!define MUI_PAGE_CUSTOMFUNCTION_LEAVE FinishLeave
!insertmacro MUI_PAGE_FINISH


This code does nothing, exactly same as before (nothing added to the finish page).

I suppose that in pre function, the dialog is already created and I should only modify already existing dialog, right? Or is it necessary to create brand new dialog by nsDialogs::Create ? I'm completly new to nsDialogs...

use MUI_PAGE_CUSTOMFUNCTION_SHOW instead of MUI_PAGE_CUSTOMFUNCTION_PRE.
http://forums.winamp.com/showthread.php?t=309799


Yes, MUI_PAGE_CUSTOMFUNCTION_SHOW instead of MUI_PAGE_CUSTOMFUNCTION_PRE was also necessary.
Now, with following piece of code, it works fine:

Var Chbx

Function FinishPageShow
${NSD_CreateCheckbox} 120u 129u 180 20 "my checkbox..."
Pop $Chbx
SetCtlColors $Chbx "" 0xffffff
${NSD_Check} $Chbx
FunctionEnd

Function FinishPageLeave
Push $0
${NSD_GetState} $Chbx $0
${If} $0 == ${BST_CHECKED}
; do something
${EndIf}
Pop $0
FunctionEnd

!define MUI_PAGE_CUSTOMFUNCTION_SHOW FinishPageShow
!define MUI_PAGE_CUSTOMFUNCTION_LEAVE FinishPageLeave
!insertmacro MUI_PAGE_FINISH


Thanks a lot, guys!