سؤال

Why is this not working?

if WizardForm <> nil then
  WizardForm.StatusLabel.Caption := 'blah'
else
  Log('WizardForm not initialized yet!');

I get this exception:

Runtime Error (at 15:118):
Internal error: An attempt was made to access WizardForm before it has been created.

I know that WizardForm is not yet initialized, that's why I check for nil, the check is not working! What am I doing wrong here?

هل كانت مفيدة؟

المحلول

That happens to every access of the WizardForm variable including the check, if it's assigned. Simply move your code from InitializeSetup event to InitializeWizard.

نصائح أخرى

Is there any other way to check for null?

How about this:

function IsWizardFormCreated(): Boolean;
begin
  Result := True;
  try
    WizardForm;
  except
    Result := False;
  end;
end;
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top