inno-setuppascalscriptinno-setup-v6

How to adjust the spacing between radio buttons and 'WizardForm.DirEdit' box?


A little while ago I asked the question: "How can I create separate install paths for Steam & Epic Games, selected by radio buttons, or a pathbox for custom install?", to which I got a great response by Martin Prikryl. Unfortunately though I ran into a little pickle due to my lack of clarifying what exactly I had planned UX-wise. I tried fixing it, but I just couldn't understand this tiny little section of his [Code] that controlled the creation of the buttons.

The section from Martin's [Code] :

var
  SteamButton: TNewRadioButton;
  EpicButton: TNewRadioButton;
  CustomButton: TNewRadioButton;

function CreateButton(var Top: Integer): TNewRadioButton;
begin
  Result := TNewRadioButton.Create(WizardForm);
  Result.Parent := WizardForm.DirEdit.Parent;
  Result.Top := Top;
  Result.Left := WizardForm.SelectDirBrowseLabel.Left;
  Result.Width := Result.Parent.ClientWidth - Result.Left;
  Result.OnClick := @DirButtonClick;
  Top := Result.Top + Result.Height + ScaleY(24); 
end;

Can anyone explain how to separate the buttons, but not the path box?


Example of what was deisred shown here:

Example Image


Solution

  • If you need different spacing after every radio button, move the spacing code out of the shared CreateButton implementation:

    SteamButton := CreateButton();
    SteamButton.Caption := '&Steam';
    SteamButton.Enabled := DirExists(SteamDirName);
    SteamButton.Top := WizardForm.SelectDirBrowseLabel.Top;
    
    EpicButton := CreateButton();
    EpicButton.Caption := '&Epic Games';
    EpicButton.Enabled := DirExists(EpicDirName);
    EpicButton.Top := SteamButton.Top + SteamButton.Height + ScaleY(24);
    
    CustomButton := CreateButton();
    CustomButton.Caption := '&Custom path:';
    CustomButton.Top := EpicButton.Top + EpicButton.Height + ScaleY(24);
    
    Top := CustomButton.Top + CustomButton.Height + ScaleY(8);
    WizardForm.DirBrowseButton.Top :=
      WizardForm.DirBrowseButton.Top + (Top - WizardForm.DirEdit.Top);
     WizardForm.DirEdit.Top := Top;
    

    And of course, remove all references to Top from CreateButton.

    enter image description here


    Another (easier-to-do) option is to make the ScaleY parameter be a parameter of the CreateButton function.