kolorowy
28th February 2013 22:50 UTC
Selected Sections Summary
I'm trying to show selected sections before installing, a summary.
I assign text to variables based on the selection. This is displayed fine, but the problem is when the section is not selected the MultiTextLine shows empty space.
If this is for the last line it is not as noticeable, if it is in the middle (TextVar2) that is mach more noticeable.
All variables are cleared before nsDialogs is created, StrCpy TextVar1 "" and so on.
If section 2 is not selected I get output such as:
Section 1
Section 3
Is there any other way of getting a summary of selected options? Initially I wanted to use NSD_CreateLabel but since not every time label will be displayed I could not find solution to move label locations if section is selected or not.
Var MultiText
Function SummaryDetails
nsDialogs::Create 1018
Pop $Dialog
${If} $Dialog == error
Abort
${EndIf}
${NSD_CreateTextMultiline} 0u 0u 100% 130u "TextVar1$\r$\nTextVar2$\r$\n\
TextVar3$\r$\n"
Pop $MultiText
nsDialogs::Show
FunctionEnd
MSG
2nd March 2013 11:41 UTC
The most straight-forward method would be to do
${If} ${SectionIsSelected} Section1
StrCpy $TextVar "$TextVar$\r$\nSection1"
${EndIf}
and keep doing that for all the sections. There's probably a smarter way, though.
oldfriend
2nd March 2013 12:19 UTC
Originally posted by MSG
The most straight-forward method would be to do
${If} ${SectionIsSelected} Section1
StrCpy $TextVar "$TextVar$\r$\nSection1"
${EndIf}
and keep doing that for all the sections. There's probably a smarter way, though.
But imagine there are 40-50 sections like in the media player installation and files type association. It won't be very convenient for every section place such part of code as for me.
Afrow UK
2nd March 2013 12:56 UTC
Then use a macro but you will still need to insert it for each section.
Edit: Or you could enumerate the sections using the SectionGet* instructions and a counter.
Stu
kolorowy
4th March 2013 17:32 UTC
Answered
Yes, that is exactly what I have done as MSG said. To eliminate the process of writing if statements for all sections, I simply loop through sections find if selected and if so get name per Afrow UK suggestions.
All left to do is meaningful section names as those are displayed.
StrCpy $SELECTED
StrCpy $R0 ${FirstSectionName} ;Index 0
IntOp $R1 $R0 + 40 ;number of all sections
Find_Sec_Loop:
; check if flag set
SectionGetFlags $R0 $SELECTED ;Start at $R0 = first section = 0
SectionGetText $R0 $SecName ;Gets section name
IntOp $SELECTED $SELECTED& ${SF_SELECTED}
IntCmp $SELECTED ${SF_SELECTED} SecSelected SecNotSelected 0 ;
SecSelected:
StrCpy $SummaryText "$SummaryText $SecName $\r$\n"
SecNotSelected: ;Do nothing
IntOp $R0 $R0 + 1
IntCmpU $R0 $R1 Find_Sec_Loop_End ;0 = 1 leave loop once it hits 40
Goto Find_Sec_Loop
Find_Sec_Loop_End: ;Finish