Search code examples
compiler-errorsinno-setuppascal

Getting an error because I'm using TSetupForm in Inno Setup Compiler Code


I setup the variable TSetupform but I'm getting an error using CenterInsideControl telling me it's unknown. Isn't CenterInsideControl a command TSetupform? Also is there something not setup correctly?

function SQLServerUserPwd_CreatePage(): Integer;
var
  SqlServerUsrPwdPage: TSetupForm;  
  Label1: TLabel;
  Label2: TLabel;
  Label3: TLabel;
  Page : TWizardPage;
  OKButton : TNewButton;
  CancelButton : TNewButton;
begin

  SqlServerUsrPwdPage := CreateCustomForm();
  SqlServerUsrPwdPage.ClientWidth := ScaleX(400);
  SqlServerUsrPwdPage.ClientHeight := ScaleY(280);
  SqlServerUsrPwdPage.Caption := CustomMessage('SqlserverUserNamePwdPageTitle');
  SqlServerUsrPwdPage.CenterInsideControl(WizardForm, False);

  Label3 := TLabel.Create(SqlServerUsrPwdPage);
  with Label3 do
  begin
    Parent := SqlServerUsrPwdPage;
    Caption := CustomMessage('SqlserverUserNamePwdPageTitleDesc')
    Left := ScaleX(16);
    Top := ScaleY(10);
    Width := ScaleX(377);
    Height := ScaleY(33);
    WordWrap := True;
  end;

end;

Here the error message I'm getting. enter image description here

I can't find the correct issue online.


Solution

  • Looking at the documentation for TSetupForm:

    TSetupForm = class(TUIStateForm)
      function CalculateButtonWidth(const ButtonCaptions: array of String): Integer;
      function ShouldSizeX: Boolean;
      function ShouldSizeY: Boolean;
      procedure FlipSizeAndCenterIfNeeded(const ACenterInsideControl: Boolean; const CenterInsideControlCtl: TWinControl; const CenterInsideControlInsideClientArea: Boolean);
      property ControlsFlipped: Boolean; read;
      property FlipControlsOnShow: Boolean; read write;
      property KeepSizeY: Boolean; read; write;
      property RightToLeft: Boolean; read;
      property SizeAndCenterOnShow: Boolean; read write;
    end;
    

    There is no CenterInsideControl function. But, in GitHub I do see:

    procedure SizeAndCenterIfNeeded(const ACenterInsideControl: Boolean;
      const CenterInsideControlCtl: TWinControl;
      const CenterInsideControlInsideClientArea: Boolean);
    

    But this function is protected.