Inno Setup Place controls on wpPreparing Page

≡放荡痞女 提交于 2021-02-05 08:01:25

问题


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?


回答1:


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...';



回答2:


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



来源:https://stackoverflow.com/questions/35707058/inno-setup-place-controls-on-wppreparing-page

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