Archive: Nested SectionGroup(s) - problem hiding Groups


Nested SectionGroup(s) - problem hiding Groups
  Hello all,

i have nested Section Groups as follows

SectionGroup"Features" SEC_GRP_FEATURES

SectionGroup"Contract Plus" SEC_GRP_FEATURES_CONTRACT_PLUS
Section/o "Building Contracts" SEC_FEATURE_CONTRACT_PLUS_BUILDING_CONTRACTS
MessageBox MB_OK "Building"
SectionEnd
Section/o "Vehicle Contracts" SEC_FEATURE_CONTRACT_PLUS_VEHICLE_CONTRACTS
MessageBox MB_OK "Vehicle"
SectionEnd
SectionGroupEnd
SectionGroup"Asset Plus" SEC_GRP_FEATURES_ASSET_PLUS
Section/o "Depreciation" SEC_FEATURE_ASSET_PLUS_DEPRECIATION
MessageBox MB_OK "Depreciation"
SectionEnd
SectionGroupEnd
SectionGroupEnd
>
Now using a

!define MUI_PAGE_CUSTOMFUNCTION_PRE "SetFeatures"

i try to disable some features depending on a given license key, the code is as follows


AmountFeatures

Var /Global AmountFeaturesAsset
Var /Global AmountFeaturesContract

StrCpy $AmountFeatures 2;Maximum Amount of Groups in Folder Features
StrCpy $AmountFeaturesAsset 1;Maximum Amount of features contained in Group SEC_GRP_FEATURES_ASSET_PLUS
StrCpy $AmountFeaturesContract 2;Maximum Amount of features contained in Group SEC_GRP_FEATURES_CONTRACT_PLUS

MessageBox MB_OK "AmountFeatures: $AmountFeatures$\r$\nAmountFeaturesAsset: $AmountFeaturesAsset$\r$\nAmountFeaturesContract :$AmountFeaturesContract"

Var /Global Inst_AssetPlus
Var /Global Inst_ContractPlus

ReadRegStr $Inst_AssetPlus HKLM"${REGKEY}" Inst_AssetPlus
ReadRegStr $Inst_ContractPlus HKLM"${REGKEY}" Inst_ContractPlus

MessageBox MB_OK "Inst_AssetPlus: $Inst_AssetPlus$\r$\nInst_ContractPlus: $Inst_ContractPlus"
${If} $Inst_AssetPlus != 1
MessageBox MB_OK "Remove Feature Asset Plus Depreciation"
!insertmacro ClearSectionFlag ${SEC_FEATURE_ASSET_PLUS_DEPRECIATION} ${SF_SELECTED}
SectionSetText ${SEC_FEATURE_ASSET_PLUS_DEPRECIATION} ""
IntOp $AmountFeaturesAsset $AmountFeaturesAsset - 1
${EndIf}

${If}$Inst_ContractPlus != 1
MessageBox MB_OK "Remove Features Contract Plus"
!insertmacro ClearSectionFlag ${SEC_FEATURE_CONTRACT_PLUS_BUILDING_CONTRACTS} ${SF_SELECTED}
SectionSetText ${SEC_FEATURE_CONTRACT_PLUS_BUILDING_CONTRACTS} ""
!insertmacro ClearSectionFlag ${SEC_FEATURE_CONTRACT_PLUS_VEHICLE_CONTRACTS} ${SF_SELECTED}
SectionSetText ${SEC_FEATURE_CONTRACT_PLUS_VEHICLE_CONTRACTS} ""
IntOp $AmountFeaturesContract $AmountFeaturesContract - 2
${EndIf}


${If}$AmountFeaturesAsset = 0
MessageBox MB_OK "Remove Feature Group Asset Plus"
!insertmacro ClearSectionFlag ${SEC_GRP_FEATURES_ASSET_PLUS} ${SF_SECGRP}
!
insertmacro ClearSectionFlag ${SEC_GRP_FEATURES_ASSET_PLUS} ${SF_SECGRPEND}
!insertmacro ClearSectionFlag ${SEC_GRP_FEATURES_ASSET_PLUS} ${SF_SELECTED}
SectionSetText ${SEC_GRP_FEATURES_ASSET_PLUS} ""
IntOp $AmountFeatures $AmountFeatures - 1
${EndIf}

${If}$AmountFeaturesContract = 0
MessageBox MB_OK "Remove Feature Group Contract Plus"
!insertmacro ClearSectionFlag ${SEC_GRP_FEATURES_CONTRACT_PLUS} ${SF_SECGRP}
!insertmacro ClearSectionFlag ${SEC_GRP_FEATURES_CONTRACT_PLUS} ${SF_SECGRPEND}
!insertmacro ClearSectionFlag ${SEC_GRP_FEATURES_CONTRACT_PLUS} ${SF_SELECTED}
SectionSetText ${SEC_GRP_FEATURES_CONTRACT_PLUS} ""
IntOp $AmountFeatures $AmountFeatures - 1
${EndIf}

${If}$AmountFeatures = 0
MessageBox MB_OK "Remove Features Group"
!insertmacro ClearSectionFlag ${SEC_GRP_FEATURES} ${SF_SECGRP}
!insertmacro ClearSectionFlag ${SEC_GRP_FEATURES} ${SF_SECGRPEND}
!insertmacro ClearSectionFlag ${SEC_GRP_FEATURES} ${SF_SELECTED}
SectionSetText ${SEC_GRP_FEATURES} ""
${EndIf}

Now if both "Features" are enabled it looks like this:

http://www.bergens.org/Clip1.jpg

If only the "Contract" Features are enabled it still looks fine.
http://www.bergens.org/Clip2.jpg

But if the Contract Features are disabled and the Asset Features are enabled it looks weird like this :(

http://www.bergens.org/Clip3.jpg

I am using NSIS Unicode 2.42-6.

any help would be much appreciated.

Thanks a lot.

Hi,

I can reproduce your problem.
It occures in the ANSI version of NSIS as well.

I think it's a bug in NSIS, because if you swap the two sectiongroups (contract and asset), the contract sectiongroup hides correctly, but the asset sectiongroup doesn't.

I don't know a workaround for this issue as well.
Sorry I can't help you further.


Thanks for reproducing, maybe someone else can shed light on this :)


Ok, after reading this post:
http://forums.winamp.com/showthread....hreadid=224801
I figured that the SectionGroupEnd needs the SF_SECGRPEND flag being cleared instead of the SectionGroup.

This is a little tricky, as to get the SectionGroupEnd identifier, you need to add 1 to the section identifier of the previous section.

You also need to make the SectionGroupEnd name "" as well (don't ask me why, but that works).

So you can leave the SF_SECGRPEND clearing of the Sectiongroup, and add the following lines after SectionSetText ${SEC_GRP_XXX_XXX} "":

IntOp $0 ${SEC_FEATURE_XXX_XXX} + 1 ; previous section
!insertmacro ClearSectionFlag $0 ${SF_SECGRPEND}
SectionSetText $0 ""

To make it clearer here is the complete working code:
Var /Global AmountFeatures 
Var /Global AmountFeaturesAsset
Var /Global AmountFeaturesContract

StrCpy $AmountFeatures 2 ;Maximum Amount of Groups in Folder Features
StrCpy $AmountFeaturesAsset 1 ;Maximum Amount of features contained in Group SEC_GRP_FEATURES_ASSET_PLUS
StrCpy $AmountFeaturesContract 2 ;Maximum Amount of features contained in Group SEC_GRP_FEATURES_CONTRACT_PLUS

MessageBox MB_OK "AmountFeatures: $AmountFeatures$\r$\nAmountFeaturesAsset: $AmountFeaturesAsset$\r$\nAmountFeaturesContract :$AmountFeaturesContract"

Var /Global Inst_AssetPlus
Var /Global Inst_ContractPlus

ReadRegStr $Inst_AssetPlus HKLM "${REGKEY}" Inst_AssetPlus
ReadRegStr $Inst_ContractPlus HKLM "${REGKEY}" Inst_ContractPlus

MessageBox MB_OK "Inst_AssetPlus: $Inst_AssetPlus$\r$\nInst_ContractPlus: $Inst_ContractPlus"
${If} $Inst_AssetPlus != 1
MessageBox MB_OK "Remove Feature Asset Plus Depreciation"
!insertmacro ClearSectionFlag ${SEC_FEATURE_ASSET_PLUS_DEPRECIATION} ${SF_SELECTED}
SectionSetText ${SEC_FEATURE_ASSET_PLUS_DEPRECIATION} ""
IntOp $AmountFeaturesAsset $AmountFeaturesAsset - 1
${EndIf}

${If} $Inst_ContractPlus != 1
MessageBox MB_OK "Remove Features Contract Plus"
!insertmacro ClearSectionFlag ${SEC_FEATURE_CONTRACT_PLUS_BUILDING_CONTRACTS} ${SF_SELECTED}
SectionSetText ${SEC_FEATURE_CONTRACT_PLUS_BUILDING_CONTRACTS} ""
!insertmacro ClearSectionFlag ${SEC_FEATURE_CONTRACT_PLUS_VEHICLE_CONTRACTS} ${SF_SELECTED}
SectionSetText ${SEC_FEATURE_CONTRACT_PLUS_VEHICLE_CONTRACTS} ""
IntOp $AmountFeaturesContract $AmountFeaturesContract - 2
${EndIf}

${If} $AmountFeaturesAsset = 0
MessageBox MB_OK "Remove Feature Group Asset Plus"
!insertmacro ClearSectionFlag ${SEC_GRP_FEATURES_ASSET_PLUS} ${SF_SECGRP}
;!insertmacro ClearSectionFlag ${SEC_GRP_FEATURES_ASSET_PLUS} ${SF_SECGRPEND}
!insertmacro ClearSectionFlag ${SEC_GRP_FEATURES_ASSET_PLUS} ${SF_SELECTED}
SectionSetFlags ${SEC_GRP_FEATURES_ASSET_PLUS} 0
SectionSetText ${SEC_GRP_FEATURES_ASSET_PLUS} ""
IntOp $0 ${SEC_FEATURE_ASSET_PLUS_DEPRECIATION} + 1 ; Add 1 to get the SEC_GRP_FEATURES_ASSET_PLUS SectionGroupEnd identifier
!insertmacro ClearSectionFlag $0 ${SF_SECGRPEND}
SectionSetText $0 ""
IntOp $AmountFeatures $AmountFeatures - 1
${EndIf}

${If} $AmountFeaturesContract = 0
MessageBox MB_OK "Remove Feature Group Contract Plus"
!insertmacro ClearSectionFlag ${SEC_GRP_FEATURES_CONTRACT_PLUS} ${SF_SECGRP}
;!insertmacro ClearSectionFlag ${SEC_GRP_FEATURES_CONTRACT_PLUS} ${SF_SECGRPEND}
!insertmacro ClearSectionFlag ${SEC_GRP_FEATURES_CONTRACT_PLUS} ${SF_SELECTED}
SectionSetFlags ${SEC_GRP_FEATURES_CONTRACT_PLUS} 0
SectionSetText ${SEC_GRP_FEATURES_CONTRACT_PLUS} ""
IntOp $0 ${SEC_FEATURE_CONTRACT_PLUS_VEHICLE_CONTRACTS} + 1 ; Add 1 to get the SEC_GRP_FEATURES_CONTRACT_PLUS SectionGroupEnd identifier
!insertmacro ClearSectionFlag $0 ${SF_SECGRPEND}
SectionSetText $0 ""
IntOp $AmountFeatures $AmountFeatures - 1
${EndIf}

${If} $AmountFeatures = 0
MessageBox MB_OK "Remove Features Group"
!insertmacro ClearSectionFlag ${SEC_GRP_FEATURES} ${SF_SECGRP}
;!insertmacro ClearSectionFlag ${SEC_GRP_FEATURES} ${SF_SECGRPEND}
!insertmacro ClearSectionFlag ${SEC_GRP_FEATURES} ${SF_SELECTED}
SectionSetFlags ${SEC_GRP_FEATURES} 0
SectionSetText ${SEC_GRP_FEATURES} ""
IntOp $0 ${SEC_FEATURE_ASSET_PLUS_DEPRECIATION} + 2 ; Add 2 to get the SEC_GRP_FEATURES SectionGroupEnd identifier
!insertmacro ClearSectionFlag $0 ${SF_SECGRPEND}
SectionSetText $0 ""
${EndIf}

Cool this works, Thanks a lot!!!