Archive: force components selection


force components selection
Hi,
i have a problem: I have a components page. The user can select and unselect each components. But I want to force him to select at least one component before going to next step with a warning in a MessageBox.
My code:

!define MUI_PAGE_CUSTUMFUNCTION_LEAVE PAGE_COMPONENTS_LEAVE
!insertmacro MUI_PAGE_COMPONENTS

Function PAGE_COMPONENTS_LEAVE

SectionGetFlags ${CSEC} $R0
IntOp $R0 $R0 & ${SF_SELECTED}
IntCmp $R0 0 +1 skip skip
MessageBox MB_OK "$R0"

SectionGetFlags ${ESEC} $R0
IntOp $R0 $R0 & ${SF_SELECTED}
IntCmp $R0 0 +1 skip skip
MessageBox MB_OK "n $R0"

SectionGetFlags ${ASEC} $R0
IntOp $R0 $R0 & ${SF_SELECTED}
MessageBox MB_OK " v $R0"
IntCmp $R0 0 +1 skip skip
MessageBox MB_OK "n $R0"
StrCpy $ComponentName ""

SectionGetFlags 3 $R0
IntOp $R0 $R0 & ${SF_SELECTED}
IntCmp $R0 0 0 skip skip
MessageBox MB_OK|MB_ICONEXCLAMATION "Please select a Component!"
Abort


skip:

FunctionEnd

Thanks for any help!!!


Function PAGE_COMPONENTS_LEAVE

SectionGetFlags ${CSEC} $R0
IntOp $R0 $R0 & ${SF_SELECTED}
StrCmp $R0 1 skip

SectionGetFlags ${ESEC} $R0
IntOp $R0 $R0 & ${SF_SELECTED}
StrCmp $R0 1 skip

SectionGetFlags ${ASEC} $R0
IntOp $R0 $R0 & ${SF_SELECTED}
StrCmp $R0 1 skip

SectionGetFlags 3 $R0
IntOp $R0 $R0 & ${SF_SELECTED}
StrCmp $R0 1 skip

MessageBox MB_OK|MB_ICONEXCLAMATION "Please select a Component!"
Abort

skip:

FunctionEnd


-Stu

Hi, thanks for your help!!
But I still have a problem:

When I use this:
!define MUI_PAGE_CUSTUMFUNCTION_LEAVE PAGE_COMPONENTS_LEAVE
!insertmacro MUI_PAGE_COMPONENTS
Function PAGE_COMPONENTS_LEAVE...

It doesn't work: I don't get the message and ... Only when I define a custom Page like this it works:
!insertmacro MUI_PAGE_COMPONENTS
Page custom PAGE_COMPONENTS_LEAVE
Function PAGE_COMPONENTS_LEAVE....

The problem is that the installation goes in the next step, so it is not what I want. Can you help me to use the first method correctly? I don't know why it doesn't work!

Thanks,

mamilo


It is just a typo, change this:
!define MUI_PAGE_CUSTUMFUNCTION_LEAVE PAGE_COMPONENTS_LEAVE
with this:
!define MUI_PAGE_CUSTOMFUNCTION_LEAVE PAGE_COMPONENTS_LEAVE

Also check section(s) index must be the same with the example function ESEC, ASEC, CSEC etc