在一些隐藏了 UserInfoPage Inno Setup 页面的机器上获取 "You must enter a name" 和 "Cannot focus a disabled or invisible window"
Getting "You must enter a name" and "Cannot focus a disabled or invisible window" on some machines with hidden UserInfoPage Inno Setup page
我做了一个快速安装程序,在一些电脑上安装时发现问题。我有“序列号”系统,当我按 “下一步” 时,出现错误
You must enter a name
然后:
Cannot focus a disabled or invisible window
但在许多其他具有相同 SO 的 PC 中,这工作正常。这是我正在使用的代码:
[Setup]
WizardStyle=modern
UserInfoPage=yes
[Code]
procedure CurPageChanged(CurPageID: Integer);
begin
if CurPageID = wpUserInfo then begin
WizardForm.UserInfoOrgLabel.Hide();
WizardForm.UserInfoOrgEdit.Hide();
WizardForm.UserInfoNameLabel.Hide();
WizardForm.UserInfoNameEdit.Hide();
end;
end;
// Presence of the CheckSerial event function displays the serial number box.
// But here we accept any non-empty serial.
// We will validate it only in the NextButtonClick,
// as the online validation can take long.
function CheckSerial(Serial: String): Boolean;
begin
Result := (Serial <> '');
end;
function NextButtonClick(CurPageID: Integer): Boolean;
var
WinHttpReq: Variant;
Url: string;
begin
Result := True;
if CurPageID = wpUserInfo then
begin
WinHttpReq := CreateOleObject('WinHttp.WinHttpRequest.5.1');
Url := 'Link that i use to check the serial number' +
WizardForm.UserInfoSerialEdit.Text;
WinHttpReq.Open('GET', Url, False);
WinHttpReq.Send('');
// Depending on implementation of the server,
// use either HTTP status code (.Status)
// or contents of returned "page" (.ResponseText)
// Here we use the HTTP status code:
// 200 = serial is valid, anything else = serial is invalid,
// and when invalid, we display .ResponseText
Result := (WinHttpReq.Status = 200);
if not Result then
MsgBox(WinHttpReq.ResponseText, mbError, MB_OK);
end;
end;
启用 UserInfoPage
后,必须填写 “用户名” 框。该框预先填入 RegisteredOwner
注册表值。如果该值恰好为空,因此该框为空,则您无法离开该页面,除非您手动填写它。您收到 “您必须输入名称” 错误,Inno Setup 将焦点移至该框。失败并显示 “无法聚焦已禁用或不可见的 window”,因为您隐藏了该框。
如果您不关心用户名,只需填写一些虚拟值:
WizardForm.UserInfoNameEdit.Text := 'foo';
我做了一个快速安装程序,在一些电脑上安装时发现问题。我有“序列号”系统,当我按 “下一步” 时,出现错误
You must enter a name
然后:
Cannot focus a disabled or invisible window
但在许多其他具有相同 SO 的 PC 中,这工作正常。这是我正在使用的代码:
[Setup]
WizardStyle=modern
UserInfoPage=yes
[Code]
procedure CurPageChanged(CurPageID: Integer);
begin
if CurPageID = wpUserInfo then begin
WizardForm.UserInfoOrgLabel.Hide();
WizardForm.UserInfoOrgEdit.Hide();
WizardForm.UserInfoNameLabel.Hide();
WizardForm.UserInfoNameEdit.Hide();
end;
end;
// Presence of the CheckSerial event function displays the serial number box.
// But here we accept any non-empty serial.
// We will validate it only in the NextButtonClick,
// as the online validation can take long.
function CheckSerial(Serial: String): Boolean;
begin
Result := (Serial <> '');
end;
function NextButtonClick(CurPageID: Integer): Boolean;
var
WinHttpReq: Variant;
Url: string;
begin
Result := True;
if CurPageID = wpUserInfo then
begin
WinHttpReq := CreateOleObject('WinHttp.WinHttpRequest.5.1');
Url := 'Link that i use to check the serial number' +
WizardForm.UserInfoSerialEdit.Text;
WinHttpReq.Open('GET', Url, False);
WinHttpReq.Send('');
// Depending on implementation of the server,
// use either HTTP status code (.Status)
// or contents of returned "page" (.ResponseText)
// Here we use the HTTP status code:
// 200 = serial is valid, anything else = serial is invalid,
// and when invalid, we display .ResponseText
Result := (WinHttpReq.Status = 200);
if not Result then
MsgBox(WinHttpReq.ResponseText, mbError, MB_OK);
end;
end;
启用 UserInfoPage
后,必须填写 “用户名” 框。该框预先填入 RegisteredOwner
注册表值。如果该值恰好为空,因此该框为空,则您无法离开该页面,除非您手动填写它。您收到 “您必须输入名称” 错误,Inno Setup 将焦点移至该框。失败并显示 “无法聚焦已禁用或不可见的 window”,因为您隐藏了该框。
如果您不关心用户名,只需填写一些虚拟值:
WizardForm.UserInfoNameEdit.Text := 'foo';