Archive: How can I use DetailPrint from within the "leave_function" of a custom page?


How can I use DetailPrint from within the "leave_function" of a custom page?
I have successfully added a custom page after "Page instfiles" to do some configuration to a file I have just installed. However, I cannot use DetailPrint within my custom page because the green text on black background detail panel is no longer visible when my custom page is displayed! Messagebox is not a good alternative. I would like to use DetailPrint or an equivalent to output lines of text in the same panel used by Page instfiles. Thanks in advance.

;...

ShowInstDetails show

Page components
Page instfiles
Page custom ShowCustom LeaveCustom ": customize"

; Cannot call Page instfiles twice or it will re-install all files again!
; Page instfiles
;...
Section "Group 2 - Option 3"
SetOutPath "c:\temp"
File "C:\stuff\myfile.txt"
SectionEnd
;...
Function LeaveCustom
; Fix me
DetailPrint "This does not display"
FunctionEnd

;...


Just wondering, but couldn't you take care of the configuration to the file at the end of the "Group 2 - Option 3" section? Why do you need a custom page? Are you getting input from the user?


You could have another InstFiles page, but before you show it you'd have to uncheck all your sections...

!include Sections.nsh
Function UncheckAll
Push $R0
StrCpy $R0 0
Loop: !insertmacro UnselectSection $R0
StrCmp $R0 ${LastSection} 0 Loop
!insertmacro SelectSection "${SpecialSection}"
Pop $R0
FunctionEnd

Your last install Section needs to be like this now:
Section "My last section" LastSection
...
SectionEnd
This'll end the range of your main install sections.

Now, you need another section under the last one. This'll be unselected at first...
Section /o "" SpecialSection
...
SectionEnd
In here, you want the code that DetailPrint's your configuration details.

That should do it. There's one problem though. The details printed in your first InstFiles page will not be in your second one. The second one will start off empty.

-Stu

Thanks for the code snippet! I will try it soon - Removing the sections after the first Page instfiles should certainly give me what I'm after!!

The reason this cannot be done in a Section is because the Section will execute on the first instfiles. Stu's suggestion circumvents this behavior.

Thanks, Stu!


Stu,

HELP!
I was not successful in implementing your UncheckAll function. I added a "Call Uncheckall" to my leave_function and it goes into an infinite loop (apparently there is no access to sections within my custom page leave_function). I'm not sure where to place the function call. I added the second "Page instfiles" command after my "Page custom". It still installs all the sections over again, since the Uncheckall function never worked. Any advice would be appreciated.


I was able to get the whole issue resolved by not using the UncheckAll function and instead manually unchceking sections:
!insertmacro UnselectSection ${g2o1}
!insertmacro UnselectSection ${g2o2}
!insertmacro UnselectSection ${g2o3}

It would be nice to use Uncheckall for maintenance purposes. It seems like Uncheckall should be calling an api to get a list of all functions before looping through them. My lack of knowledge, I suppose. Stu, should you resolve the section looping issue, all would benefit from a working function.
Thanks for the usage tips on the macros. Where are these documented?


Uhm yes I see the problem...

!include Sections.nsh
Function UncheckAll
Push $R0
StrCpy $R0 0
Loop: !insertmacro UnselectSection $R0
IntOp $R0 $R0 +1
StrCmp $R0 ${LastSection} 0 Loop
!insertmacro SelectSection "${SpecialSection}"
Pop $R0
FunctionEnd


Needed to increment $R0 by one every time.
Each section in an installer has an index; ie the first section is at index 0, the second is at 1 and so on.
When you use
Section "my section" SecID
SectionEnd
${SecID} will be defined as (or rather, it will contain) the section index of that section.

So the function loops from 0 till it reaches ${LastSection} unselecting each one.
Then I've put in
!insertmacro SelectSection "${SpecialSection}"
to re-select your special section for the 2nd install files page, because it is unselected as default (using the /o switch)

-Stu