Reputation: 33
I have three components and if the user select any component it will do installations. Now I want to disable the Next button if the user don't select any components.
I am trying if not IsComponentSelected('xxx')
, but it is not working. Can anyone please help me??
Upvotes: 2
Views: 1379
Reputation: 202534
There's no easy way to update the Next button state on component selection change.
A way easier is to display a message when the Next button is clicked:
function NextButtonClick(CurPageID: Integer): Boolean;
begin
Result := True;
if CurPageID = wpSelectComponents then
begin
if WizardSelectedComponents(False) = '' then
begin
MsgBox('No component selected', mbInformation, MB_OK);
Result := False;
end;
end;
end;
If you insist on disabling the Next button, use this:
var
TypesComboOnChangePrev: TNotifyEvent;
procedure ComponentsListCheckChanges;
begin
WizardForm.NextButton.Enabled := (WizardSelectedComponents(False) <> '');
end;
procedure ComponentsListClickCheck(Sender: TObject);
begin
ComponentsListCheckChanges;
end;
procedure TypesComboOnChange(Sender: TObject);
begin
{ First let Inno Setup update the components selection }
TypesComboOnChangePrev(Sender);
{ And then check for changes }
ComponentsListCheckChanges;
end;
procedure InitializeWizard();
begin
WizardForm.ComponentsList.OnClickCheck := @ComponentsListClickCheck;
{ The Inno Setup itself relies on the WizardForm.TypesCombo.OnChange, }
{ so we have to preserve its handler. }
TypesComboOnChangePrev := WizardForm.TypesCombo.OnChange;
WizardForm.TypesCombo.OnChange := @TypesComboOnChange;
end;
procedure CurPageChanged(CurPageID: Integer);
begin
if CurPageID = wpSelectComponents then
begin
ComponentsListCheckChanges;
end;
end;
To understand why you need so much code for such a little task, see Inno Setup ComponentsList OnClick event
Upvotes: 1