So the question is this: I asked a question back here: How to allow installation only to a specific folder?
How can I modify it a bit, so for example, I have 3 files to install, 2 of them are optional and should only be available to install, if a certain file/folder exists. I want to grey out the option to select them in the list, if the conditions are not met?
Thank you in advance. Zsolt
I would try to do the following. It will access the component list items, disable and uncheck them by their index, what is the number starting from 0 taken from the order of the [Components]
section. The items without fixed
flag (like in this case) are by default enabled, thus you need to check if the condition has not been met instead. You may check also the commented version
of this post:
[Components]
Name: Component1; Description: Component 1
Name: Component2; Description: Component 2
Name: Component3; Description: Component 3
[code]
procedure CurPageChanged(CurPageID: Integer);
begin
if CurPageID = wpSelectComponents then
if not SomeCondition then
begin
WizardForm.ComponentsList.Checked[1] := False;
WizardForm.ComponentsList.ItemEnabled[1] := False;
WizardForm.ComponentsList.Checked[2] := False;
WizardForm.ComponentsList.ItemEnabled[2] := False;
end;
end;
The solution above has at least one weakness. The indexes might be shuffled from the original order from the [Components]
section when you set the ComponentsList.Sorted
to True. If you don't
use it, it might be enough to use the above code, if yes, then it's more complicated.
There is no simple way to get the component name (it is stored internally as TSetupComponentEntry
object in the ItemObject
of each item), only the description, so here is another way to do the same with the difference that the item indexes are being searched by their descriptions specified.
procedure CurPageChanged(CurPageID: Integer);
var
Index: Integer;
begin
if CurPageID = wpSelectComponents then
if not SomeCondition then
begin
Index := WizardForm.ComponentsList.Items.IndexOf('Component 2');
if Index <> -1 then
begin
WizardForm.ComponentsList.Checked[Index] := False;
WizardForm.ComponentsList.ItemEnabled[Index] := False;
end;
Index := WizardForm.ComponentsList.Items.IndexOf('Component 3');
if Index <> -1 then
begin
WizardForm.ComponentsList.Checked[Index] := False;
WizardForm.ComponentsList.ItemEnabled[Index] := False;
end;
end;
end;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With