Getting "You must enter a name" and "Cannot focus a disabled or invisible window" on some machines with hidden UserInfoPage Inno Setup page

Viewed 122

I have made a quick installer and in some PC I have found problems when installing. I have "serial number" system and when I press "Next" it gives me an error

You must enter a name

and then:

Cannot focus a disabled or invisible window

But in many other PCs with same SO this works normal. This is the code that I am using:

[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;
1 Answers

With UserInfoPage enabled, filling in the "User name" box is mandatory. The box is pre-filled with a value of RegisteredOwner registry value. If that value happens to be empty, and consequently the box, you cannot leave the page, until you fill it in manually. You get the "You must enter a name" error and Inno Setup moves the focus to the box. That fails with "Cannot focus a disabled or invisible window", as you have the box hidden.

If you do not care about the username, just fill in some dummy value:

WizardForm.UserInfoNameEdit.Text := 'foo';
Related