Archive: Newbie: Needs Help With Component Sections 1 over 4


Newbie: Needs Help With Component Sections 1 over 4
Newbie: This it my first week 1/2 using Nullsoft and i have hit a brickwall
I need help with the Components Page Sections. I have 4 Sections each one is unique, but only 1 Section can installed, if two or more Sections are installed the last on that was writen to the haard drive is used. But that one may not be the one that is needed. So basically I need the Sections to swich off with only one Section or none being selected in the Components Page of my installer.


One way i know of to do this is like this. (But it only covers 2 Sections.) And I need it to cover 4 Sections. Please Help

;-----------------------
Function .onSelChange
Push $0

StrCmp $R9 ${sec1}

SectionGetFlags ${sec1} $0
IntOp $0 $0 & ${SF_SELECTED}
IntCmp $0 ${SF_SELECTED} 0 done done
StrCpy $R9 ${sec1}
SectionGetFlags ${sec2} $0
IntOp $0 $0 & ${SECTION_OFF}
SectionSetFlags ${sec2} $0

Goto done

check_sec1:

SectionGetFlags ${sec2} $0
IntOp $0 $0 & ${SF_SELECTED}
IntCmp $0 ${SF_SELECTED} 0 done done
StrCpy $R9 ${sec2}
SectionGetFlags ${sec1} $0
IntOp $0 $0 & ${SECTION_OFF}
SectionSetFlags ${sec1} $0
done:
FunctionEnd
;-----------------------

An summery of what I have tryed to do so far is hopefully at the bottum of the page in .nsi format [Note] The .nsi file was Compiled with Venis IX.










Here is Summery.nsi
;----------------------

;AUTHOR:PCEnhancer
;REQUIRES:Windows 2000/XP
BrandingText "Cool v1.2"
;--------------------------------
;Include Modern UI
!include "MUI.nsh"
;--------------------------------
;General

;Name and file
!define APPNAME "Cool"
!define APPNAMEANDVERSION "Cool v1.2"
Name "${APPNAMEANDVERSION}"
OutFile "Cool Need Help.exe"

;Default installation folder
InstallDir "$DESKTOP\Cool"
InstallDirRegKey HKLM "Software\${APPNAME}" ""
;--------------------------------
;Variables

Var MUI_TEMP
;--------------------------------
;Interface Configuration

!define MUI_BGCOLOR 000000
!define MUI_COMPONENTSPAGE_SMALLDESC
!define MUI_COMPONENTSPAGE_TEXT_COMPLIST ""
!define MUI_COMPONENTSPAGE_TEXT_INSTTYPE ""
;--------------------------------
;Pages

!insertmacro MUI_PAGE_COMPONENTS
!insertmacro MUI_PAGE_DIRECTORY
;!insertmacro MUI_PAGE_INSTFILES
;--------------------------------
;Languages

!insertmacro MUI_LANGUAGE "English"
;--------------------------------
;Installer Sections

;Set Section properties
SetOverwrite on

ShowInstDetails "show"
;--------------------------------
SubSection /e "Install Cool Cursors [ACTIVE]" "Hello"

Section "Install Cursors as [ACTIVE]" sec1
SectionEnd
;--------------------------------
Section "Install Cursors Burnt as [ACTIVE]" sec2
;Wright Data "Cool Cursors" to Registry
SectionEnd
;--------------------------------
Section "Install Cursors Solid as [ACTIVE]" sec3
;Wright Data "Cool Cursors" to Registry
SectionEnd
;--------------------------------
Section "Install Cursors Burnt Solid as [ACTIVE]" sec4
SectionEnd
SubSectionEnd
;-------------------------------------------------------


;HERE IS THE PROBLEM!!!!!!!!
;--------------------------------------
Function .onInit
System::Call 'kernel32::CreateMutexA(i 0, i 0, t "myMutex") i .r1 ?e'

Pop $R0

StrCmp $R0 0 +3
MessageBox MB_OK "The installer is already running."
Abort
;------------------------
Push $0

StrCpy $R9 ${sec1} ; Gotta remember which section we are at now...
SectionGetFlags ${sec1} $0
IntOp $0 $0 | ${SF_SELECTED}
SectionSetFlags ${sec1} $0

SectionGetFlags ${sec2} $0
IntOp $0 $0 & ${SECTION_OFF}
SectionSetFlags ${sec2} $0

SectionGetFlags ${sec3} $0
IntOp $0 $0 & ${SECTION_OFF}
SectionSetFlags ${sec3} $0

SectionGetFlags ${sec4} $0
IntOp $0 $0 & ${SECTION_OFF}
SectionSetFlags ${sec4} $0

Pop $0
FunctionEnd

;I Need Help With This Right Here.
;-------------------------------------------
Function .onSelChange
Push $0

StrCmp $R9 ${sec1} check_sec1

SectionGetFlags ${sec1} $0
IntOp $0 $0 & ${SF_SELECTED}
IntCmp $0 ${SF_SELECTED} 0 done done
StrCpy $R9 ${sec1}
SectionGetFlags ${sec2} $0
IntOp $0 $0 & ${SECTION_OFF}
SectionSetFlags ${sec2} $0

Goto done

check_sec1:

SectionGetFlags ${sec2} $0
IntOp $0 $0 & ${SF_SELECTED}
IntCmp $0 ${SF_SELECTED} 0 done done
StrCpy $R9 ${sec2}
SectionGetFlags ${sec1} $0
IntOp $0 $0 & ${SECTION_OFF}
SectionSetFlags ${sec1} $0

Goto done
;done:
;-------------------------------------------
Pop $0

Push $0

StrCmp $R9 ${sec3} check_sec3

SectionGetFlags ${sec3} $0
IntOp $0 $0 & ${SF_SELECTED}
IntCmp $0 ${SF_SELECTED} 0 done done
StrCpy $R9 ${sec3}
SectionGetFlags ${sec4} $0
IntOp $0 $0 & ${SECTION_OFF}
SectionSetFlags ${sec4} $0

Goto done

check_sec3:

SectionGetFlags ${sec4} $0
IntOp $0 $0 & ${SF_SELECTED}
IntCmp $0 ${SF_SELECTED} 0 done done
StrCpy $R9 ${sec4}
SectionGetFlags ${sec3} $0
IntOp $0 $0 & ${SECTION_OFF}
SectionSetFlags ${sec3} $0

done:

Pop $0
FunctionEnd


Hello

i ve got the same problems a few weeks ago,

as fas as i remember, i only add this
Function .onSelChange


!insertmacro StartRadioButtons $1
!insertmacro RadioButton ${SecStandard}
!insertmacro RadioButton ${SecLocal}
!insertmacro RadioButton ${SecWeb}
!insertmacro EndRadioButtons

FunctionEnd
SecStandard;SecLocal,SecWeb are the name of your section

and you have to add this at the begining of your script
!include "Sections.nsh"

I 'm not sure of this, but it should work.
If it doesn't work try to look on the example directory of your nsis folder, there is an example.


Thanks for your Reply. You were right about there an example in the nsis directory. I found "one-section.nsi" and altered it to this and now it works ok, there is a small bug with it in the SubSection, if in the installer you click on that sud section it highlight all the section but one. But hay it works so far. Thanks


Function .onInit

Push $0

StrCpy $1 ${sec9}
SectionGetFlags ${sec9} $0
IntOp $0 $0 | ${SF_SELECTED}
SectionSetFlags ${sec9} $0

SectionGetFlags ${sec10} $0
IntOp $0 $0 & ${SECTION_OFF}
SectionSetFlags ${sec10} $0

SectionGetFlags ${sec11} $0
IntOp $0 $0 & ${SECTION_OFF}
SectionSetFlags ${sec11} $0

SectionGetFlags ${sec12} $0
IntOp $0 $0 & ${SECTION_OFF}
SectionSetFlags ${sec12} $0

Pop $0

FunctionEnd

Function .onSelChange

!insertmacro StartRadioButtons $1
!insertmacro RadioButton ${sec1}
!insertmacro RadioButton ${sec2}
!insertmacro RadioButton ${sec3}
!insertmacro RadioButton ${sec4}
!insertmacro EndRadioButtons

FunctionEnd


Replaces!!!
;-----------

Push $0

StrCpy $R9 ${sec1} ; Gotta remember which section we are at now...
SectionGetFlags ${sec1} $0
IntOp $0 $0 | ${SF_SELECTED}
SectionSetFlags ${sec1} $0

SectionGetFlags ${sec2} $0
IntOp $0 $0 & ${SECTION_OFF}
SectionSetFlags ${sec2} $0

SectionGetFlags ${sec3} $0
IntOp $0 $0 & ${SECTION_OFF}
SectionSetFlags ${sec3} $0

SectionGetFlags ${sec4} $0
IntOp $0 $0 & ${SECTION_OFF}
SectionSetFlags ${sec4} $0

Pop $0
FunctionEnd

;I Need Help With This Right Here.
;-------------------------------------------
Function .onSelChange
Push $0

StrCmp $R9 ${sec1} check_sec1

SectionGetFlags ${sec1} $0
IntOp $0 $0 & ${SF_SELECTED}
IntCmp $0 ${SF_SELECTED} 0 done done
StrCpy $R9 ${sec1}
SectionGetFlags ${sec2} $0
IntOp $0 $0 & ${SECTION_OFF}
SectionSetFlags ${sec2} $0

Goto done

check_sec1:

SectionGetFlags ${sec2} $0
IntOp $0 $0 & ${SF_SELECTED}
IntCmp $0 ${SF_SELECTED} 0 done done
StrCpy $R9 ${sec2}
SectionGetFlags ${sec1} $0
IntOp $0 $0 & ${SECTION_OFF}
SectionSetFlags ${sec1} $0

Goto done
;done:
;-------------------------------------------
Pop $0

Push $0

StrCmp $R9 ${sec3} check_sec3

SectionGetFlags ${sec3} $0
IntOp $0 $0 & ${SF_SELECTED}
IntCmp $0 ${SF_SELECTED} 0 done done
StrCpy $R9 ${sec3}
SectionGetFlags ${sec4} $0
IntOp $0 $0 & ${SECTION_OFF}
SectionSetFlags ${sec4} $0

Goto done

check_sec3:

SectionGetFlags ${sec4} $0
IntOp $0 $0 & ${SF_SELECTED}
IntCmp $0 ${SF_SELECTED} 0 done done
StrCpy $R9 ${sec4}
SectionGetFlags ${sec3} $0
IntOp $0 $0 & ${SECTION_OFF}
SectionSetFlags ${sec3} $0

done:

Pop $0
FunctionEnd

And it Works, Thanks Again.:)