Disable controls based on components selection in Inno Setup

你说的曾经没有我的故事 提交于 2019-11-29 08:41:23

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 IsComponentSelected('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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!