Archive: Sections must be selected


Sections must be selected
I have an installer with sections all unselected(SECTION_OFF)
the customer must be select the section if he want to continue the installation.
Now if I dont select any section the I have the installation folder on my desktop with the readme and license installed because i have the following code(I WANT THIS)
Section "-General Readme/License"

SectionIn RO
SetOutPath "$INSTDIR"
File "${NSISDIR}\Examples\License.txt"
File "${NSISDIR}\Examples\Readme.txt

The others section are:
Function .onInit

SectionGetFlags ${sec1} $0
IntOp $0 $0 & ${SECTION_OFF}
SectionSetFlags ${sec1} $0
there is a total of 10 sections
Thank you in advance


Sorry, what is your question?
Do you want it so that atleast 1 section has to be selected to install?

-Stu


If so, then you need to do this...
For Modern UI, you need to have a leave function of your components page


!define MUI_CUSTOMFUNCTION_COMPONENTS_LEAVE "CheckComponents"

Function CheckComponents
## Check if atleast one component is selected
## ------------------------------------------
SectionGetFlags ${Sec1} $R0
StrCmp $R0 1 done
SectionGetFlags ${Sec2} $R0
StrCmp $R0 1 done
SectionGetFlags ${Sec3} $R0
StrCmp $R0 1 done
SectionGetFlags ${Sec4} $R0
StrCmp $R0 1 done
SectionGetFlags ${Sec5} $R0
StrCmp $R0 1 done
SectionGetFlags ${Sec6} $R0
StrCmp $R0 1 done
SectionGetFlags ${Sec7} $R0
StrCmp $R0 1 done
SectionGetFlags ${Sec8} $R0
StrCmp $R0 1 done
SectionGetFlags ${Sec9} $R0
StrCmp $R0 1 done
SectionGetFlags ${Sec10} $R0
StrCmp $R0 1 done

MessageBox MB_OK|MB_ICONEXCLAMATION "Please select a component to install!"
Abort ;goes back to page

done: ;if component was selected
FunctionEnd


If you aren't using Modern UI (you should!) then define the custom leave function like so:
Page Components "" "" "CheckComponents"

-Stu

Thank you ...yes I forgot to mention it "Im using MUI".
I wrote your code in the installer, it work very well.
Now m going to understaind
Thank you a lot.


No problem :)
Its very simple.

Sections are "1" if selected and "0" if not selected.
SectionGetFlags gets the section state.
"StrCmp $R0 1 done" will goto the end of the function (done label) because that shows that one of the components is selected.
If none are selected (all are state "0") then it will reach the error message box.

Btw, remove the "Push $R0" from the start, that isn't needed.

-Stu


Another question...
You wrote this command MB_ICONEXCLAMATION.
ITS possible to change the ICON????
Insert another icon.


You cannot insert any icon unfortunately.
You can only have ICONS from Windows standard message boxes:

See section 4.9.4.14 of the NSIS user manual on the MessageBox command:

http://nsis.sourceforge.net/Docs/Chapter4.html#4.9.4.14

-Stu


Ok thanks again ...I can use the stop icon or the icon in the script.
I think the Stop icon will be great.
Its coming more intresting .......
Probably Im bothering you but my installer have a long name about 50 letters (I have different collection for every years) and i want see the collection name during the installation.
May I change the lenght of the installer "MUI_CUSTOMFUNCTION_COMPONENTS_LEAVE"


So, you have a piece of text that is <50 characters long and you want it to be displayed in a MessageBox?
You can indeed add a MessageBox anywhere you like - in Functions and Sections.

You should have a look at all of the MUI Custom Functions available (read Contrib\Modern UI\Readme.html) - there's PRE SHOW and LEAVE functions for all Modern UI pages.
PRE is called before the page loads
SHOW is called when the page loads
LEAVE is of course called when the user clicks the next button

E.g.
!define MUI_CUSTOMFUNCTION_WELCOME_PRE WelcomeFunction
!define MUI_CUSTOMFUNCTION_INSTFILES_LEAVE InstFilesFunction

etc

It's probably better to display your string on an InstallOptions dialog (look in Contrib\InstallOptions and compile test.nsi script, also look at the Readme.html file.)

-Stu


Thanks so much ....im going to try tonight...ill let you know tomorrow.


Thank you Afrow UK its wworking ...great