Archive: Disable section


Disable section
  Good evening ladies and gents,

I noticed a pretty cool quirk with NSIS. If you want to have a deselected grayed-out section, you use the syntax:


Section /o SectionName

SectionIn RO
>...
>SectionEnd
>
Any ideas on how to make this happen inside a function? Specifically, I want to make a function that searches for a component on the client's computer. If the component is there and up-to-date, the section should be grayed-out. Currently I have an InstallOptions page that somewhat emulates what I'm going for, but this way would be so much easier to support.

Thanks for any help,
Joe

That's no quirk. It's simply a section with SF_RO and without SF_SELECTED.


Ah, well my apologies for the mistaken terminology. So what I'm gathering from your post is, in order to check if a section is selected, I need to check the variable ${SF_SELECTED}. Is changing this in the background as simple as using !define? If that's the case, I could just do this in a function, no?

Thanks
Joe


In order to check if a section is selected, you need to get its flags using SectionGetFlags and check if the ${SF_SELECTED} flag is set. It's not a variable and I'm not sure what you mean by changing it in the background.

To set the flags, you can use SectionSetFlags. Clear the SF_SELECTED flag, and set the SF_RO flag.

You can use the macros in Sections.nsh for all of the above. Use SectionFlagIsSet to check if a section is selected, SetSectionFlag to set a section flag and ClearSectionFlag to clear a section flag. The LogicLib has macros to handle section selection as well. Examples\LogicLib.nsi has an example of this in the ComponentsLeave function.


Sorry for the ambiguous wording. Your suggestion of using SetSectionFlag and ClearSectionFlag macros were exactly what I was looking for. I guess I must of overlooked that solution (my bad).

Thanks
Joe