Archive: MUI - Conditional custom and Components page


MUI - Conditional custom and Components page
I have been working on an application portal and ended up in a bit of a predicament.

I am using a MUI interface with a custom page containing a text field and a password field. I only want the custom page to come up if a registry value does not exist. If it does exist, I want it to go straight to the components page.

The second part that I am needing help with is that I want the sections under the Component page altered by data that is read and verified by a seperate function of the installer. I need sections created/checked/disabled(RO)/hidden depending on the data that is provided. Using SectionSetFlags, I can do everything but create dynamic sections and make the sections visable or hidden.

Thanks for any help you might provide.

- DF


Look at this:
http://forums.winamp.com/showthread.php?threadid=220709
and
http://forums.winamp.com/showthread.php?threadid=220713

-Stu


Thanks again Afro UK. I got the first part of skipping a custom MUI page based on a registry key.

The second part is still a problem though. I looked at your second link, and in that case, x-nem wanted to skip custom pages based on if a component was selected to install or not.

What I am looking at doing is using an INI file to specify the components. Like so:

[1]
Name=MyApp
Location=\\blah\subfolder\blah.exe
Required=Yes

[2]
...

So I would need to use a loop to read out the components to be displayed (as well as what to execute) on the first Components page.

Thanks again
- DF


You cannot dynamically add components. There's a fixed amount (set with Section's) on compile-time.

-Stu


Ok, last question.

Is there a way to hide a section from the components page? I didnt see an option like that with SectionSetFlags.

- DF

edit: Besides hard-coding it into the section syntax.


You just need to set the section name to "" with SectionSetText

-Stu


Awsome. Thanks a ton Afrow UK. Your the best. :D

- DF


Gah! Thought I was all done. I am having a problem with the SetSectionText command.

This is the scenario right now:
There are 2 sections, MyApp and AnotherApp, in that order. Both components are hidden by default. My functions display and enable AnotherApp. With using the .onSelChange function, when I check and uncheck the box, it enables and disables both components.

Any suggestions?

- DF


Sorry, what's the actual question / problem.

Edit: Or rather, what do you need it to do instead.

-Stu


Ok, heres what Im trying to do.

By default, I hide all my sections. In this case, there are only 2.

So I got something like this:

Section "-MyApp" MyApp
DetailPrint "Blah1"
SectionEnd

Section "-AnotherApp" AnotherApp
DetailPrint "Blah2"
SectionEnd

---
Then I have a function reading an ini file and making the sections visible as needed.

For the test I was running, MyApp was going to stay hidden, and AnotherApp was going to appear. The syntax I am using is this:

SetSectionText AnotherApp "AnotherApp"

This makes only AnotherApp be displayed on the componets page. So, that works so far.

To test this, I made the following function.

Function .onSelChange
SectionGetFlags MyApp $0
MessageBox MB_OK "MyApp: $0"
SectionGetFlags AnotherApp $0
MessageBox MB_OK "AnotherApp: $0"
FunctionEnd

Now, when I check the AnotherApp box on the components page, I get MyApp Flags = 1 and AnotherApp Flags = 1. When I uncheck the box, I get MyApp = 0 and AnotherApp = 0.

So the one checkbox that is being displayed is really controlling both MyApp and AnotherApp.

What Im going to try to do this morning (USA) is take out my functions. I have a lot of other things going on in the background and it could be causing problems.

- DF


Just finished with my testing. The problem seems to be with how the Section Flags really work. Even if the SectionGetFlags = 1, then that doesnt necessarily mean that it will run the install for that app. Same with 0 and not running the specified section.

Maybe I am just trying to use the Section Flags in a way that they arent meant to be used. Attached is my concept nsi. Under the .onInit function, I am setting AnotherApp Section Flags to 1.
If I do that, then the MyApp checkbox on the components page is checked and so is the AnotherApp checkbox.
If AnotherApp Section Flags is set to 0, then the MyApp Checkbox on the components page is UNchecked and AnotherApp checkbox is still checked.

What I am needing to do is have the ability to control which checkboxes are checked and which ones arent. I thought SectionSetFlags could do that, but maybe Im missing something?

- DF


Ideally you should use the SetSectionFlag and ClearSectionFlag macros in Sections.nsh:

!include Sections.nsh

Function .onInit
!insertmacro SetSectionFlag ${secID} ${SF_SELECTED}
FunctionEnd

Edit: And to check if a Section is selected, use the SectionIsSelected macro.

-Stu


Section flags are combinations of different settings. Use the Section.nsh macros to check whether a section is selected or not.


Ok, got another one. Sorry for all the questions...

When using the macro:

!insertmacro SetSectionFlag ${secID} ${SF_SELECTED}

is there a way to use a variable for the SectionID?

Thanks again,

- DF

[EDIT]
That and I just noticed that I cant use plain numbers instead of the SF_SELECTED. How would I control RO/RW (setflags bit would be 17) using the macro?

Nevermind the above statement... no coffee... :(


SF_SELECTED and SF_RO are plain numbers. They're defines in Sections.nsh

The SectionID is also just a plain number. The first Section will have an index of 0 (also SectionGroup and SectionGroupEnd's take up section slots).

-Stu


Alright! Got everything working. Hopefully for sure this time. Thanks again for all the help. :up:

- DF