I would like to be able to disable the selection of a component based on a specific component being selected. I cannot do this through nesting of components, as the component needs to be selectable on it's own, but not if another specific component is selected. Currently I handle this using the NextButtonClick
event displaying a message:
if IsComponentSelected('Client') and IsComponentSelected('Sync') then
begin
MsgBox('A Client installation cannot have the Synchronisation component selected.',
mbError, MB_OK);
Result := False;
end;
which prevents the user from continuing until they deselect the incompatible combination. However, it would be far more elegant if I could simply disable the selection of the component rather than displaying a message:
if CurPageID = wpSelectComponents then
begin
if IsComponentSelected('Client') then
begin
WizardForm.ComponentsList.Checked[15] := False;
WizardForm.ComponentsList.ItemEnabled[15] := False;
end
else
begin
WizardForm.ComponentsList.ItemEnabled[15] := True;
end;
end;
The problem is there doesn't seem to be an event that allows this to change dynamically as the user selects or deselects components. Is there an event I can place this code in or another way to do this?
The code I used in the end is based entirely on @TLama's code that he provided previously as this does not require the use of an external DLL.
Although this and @RobeN's solutions both work, they both exhibit a graphical update issue i.e. when changing the status of the components from active to disabled and vice versa, the text doesn't automatically dim or undim until the scroll bar is dragged.
Note that the refresh issue described above is resolved by adding an `Invalidate;' line. Code updated above with a comment to reflect this. See Inno Setup Components graphical refresh issue for further information. Thanks @TLama.
You had TLama's solution which was probably better than the following, but still this code is also a way to achieve the goal (though you will need innocallback.dll):