Robert Wigley
Robert Wigley

Reputation: 1957

Inno Setup Place controls on wpPreparing Page

I am trying to place a label on the wpPreparing page to indicate uninstallation of an existing version, prior to running the new installation. Here is my code:

function PrepareToInstall(var NeedsRestart: Boolean): String;
var
  UninstallingLabel: TNewStaticText;
  intResultCode: Integer;
begin
  with UninstallingLabel do
    begin
      Caption := 'Uninstalling existing version...';
      Left := WizardForm.StatusLabel.Left;
      Top := WizardForm.StatusLabel.Top;
      Parent := wpPreparing.Surface;
    end;
  if strExistingInstallPath <> '' then
    begin
      Exec(GetUninstallString, '/verysilent /suppressmsgboxes', '', SW_HIDE,
        ewWaitUntilTerminated, intResultCode);
    end;
end;

The trouble is it does not seem to like Parent := wpPreparing.Surface and compiling fails with a

Semicolon (;) expected

error. This syntax works when adding a label to a custom created page. Why does this fail when trying to add it to wpPreparing?

Upvotes: 1

Views: 605

Answers (2)

Martin Prikryl
Martin Prikryl

Reputation: 202642

The wpPreparing is not an object, it's just a numerical constant.

The WizardForm.PreparingPage holds a reference to the "Preparing to Install" page. Note that it is of type TNewNotebookPage already, not TWizardPage. So you use it directly as a parent.


Also note that the StatusLabel is on the "Installing" page. You probably want to relate your new label to the PreparingLabel instead.


And you have to create the UninstallingLabel.


UninstallingLabel := TNewStaticText.Create(WizardForm);

with UninstallingLabel do
begin
  Caption := 'Uninstalling existing version...';
  Left := WizardForm.PreparingLabel.Left;
  Top := WizardForm.PreparingLabel.Top;
  Parent := WizardForm.PreparingPage;
end;

Though do you really want to shadow the PreparingLabel (as you use its coordinates).

What about reusing it instead?

WizardForm.PreparingLabel.Caption := 'Uninstalling existing version...';

Upvotes: 1

Marco Rebsamen
Marco Rebsamen

Reputation: 605

I've replayed your code. It works if you use just WizardForm as the parent. But it's in the top left corner of the form...

wpPreparing is the name of a constant that holds the ID of the correspnding page.

And you have to create an instance of UninstallingLabel

Upvotes: 1

Related Questions