Inno Setup在wpPreparing页面上放置控件 [英] Inno Setup Place controls on wpPreparing Page
问题描述
我试图在运行新安装之前在 wpPreparing
页面上放置一个标签,以指示已卸载现有版本.这是我的代码:
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;
麻烦之处在于它似乎不喜欢 Parent:= wpPreparing.Surface
,并且编译失败并显示
The trouble is it does not seem to like Parent := wpPreparing.Surface
and compiling fails with a
期望用分号(;)
Semicolon (;) expected
错误.将标签添加到自定义创建的页面时,此语法有效.为什么在尝试将其添加到 wpPreparing
时失败?
error. This syntax works when adding a label to a custom created page. Why does this fail when trying to add it to wpPreparing
?
推荐答案
wpPreparing
不是对象,只是一个数字常量.
The wpPreparing
is not an object, it's just a numerical constant.
WizardForm.PreparingPage
包含对准备安装"页面的引用.请注意,它已经是 TNewNotebookPage
类型,而不是 TWizardPage
类型.因此,您可以直接将其用作父项.
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.
还请注意, StatusLabel
位于安装"页面上.您可能想将新标签关联到 PreparingLabel
.
Also note that the StatusLabel
is on the "Installing" page. You probably want to relate your new label to the PreparingLabel
instead.
并且您必须创建 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;
尽管您确实要遮蔽 PreparingLabel
(因为使用其坐标).
如何重用它呢?
WizardForm.PreparingLabel.Caption := 'Uninstalling existing version...';
这篇关于Inno Setup在wpPreparing页面上放置控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!