Disable controls based on components selection in Inno Setup

后端 未结 1 1217
予麋鹿
予麋鹿 2020-12-18 11:15

I\'d like to disable controls on my custom page (VST2DirPage) based on selected components. I have tried the condition:



        
相关标签:
1条回答
  • 2020-12-18 11:34

    InitializeWizard event function happens even before the installer is shown. At that point, you do not know yet, what components a user will select.

    You have to update a controls' state only when you know what components are selected:

    • Either when leaving the "Select Components" page.
    • Or when entering your custom page.

    This shows the later approach (implemented using CurPageChanged event function):

    procedure CurPageChanged(CurPageID: Integer);
    begin
      if CurPageID = VST2DirPage.ID then
      begin
        VST2DirPage.Buttons[0].Enabled := not WizardIsComponentSelected('VST64');
        VST2DirPage.PromptLabels[0].Enabled := VST2DirPage.Buttons[0].Enabled;
        VST2DirPage.Edits[0].Enabled := VST2DirPage.Buttons[0].Enabled;
      end;
    end;
    

    Note that the above code not only disables the controls, when the component is selected. It also re-enables them, if user returns back to "Select Components" page and unselects the component.


    See also a similar question:
    Inno Setup - Change a task description label's color and have a line break.

    0 讨论(0)
提交回复
热议问题