TAdvEdit onValueValidate

Hi,
Why does the event below fire when the form is closed? Of course, it throws it as an error
'Cannot focus a disabled or invisible window'

   advedtDatabaseName: TAdvEdit;

procedure TfrmRestoreDB.advedtDatabaseNameValueValidate(Sender: TObject; Value: string; var IsValid: Boolean);
begin
  advedtDatabaseName.SetFocus;
end;

Is the TAdvEdit value changed, it is expected that OnValueValidate will be called. You'll need to check whether the form is being closed to prevent to call SetFocus.
When the value was not changed, we cannot see here that this event is triggered.

I agree with what you wrote. But my experience says something else.
I made an attempt.
When starting, the message is shown twice.
The form does not respond to any of the system buttons. Only a notification is always displayed.
Note that the system buttons are not drawn well. They are bright.
Just add another component to the form that knows the focus and will have a lower TabOrder value.
Problems will disappear.

unit MainForm;

interface

uses
System.Classes, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls,
AdvEdit;

type
TfrmMainForm = class(TForm)
advedt2: TAdvEdit;
procedure advedt1ValueValidate(Sender: TObject; Value: string; var IsValid: Boolean);
end;

var
frmMainForm: TfrmMainForm;

implementation

{$R *.dfm}

procedure TfrmMainForm.advedt1ValueValidate(Sender: TObject; Value: string; var IsValid: Boolean);
begin
ShowMessage('advedt1ValueValidate');
end;

end.
2022 10 16 18 31 31 Dokument1_-_Microsoft_Word

I still cannot see "Cannot focus a disabled or invisible window" but we applied an improvement that will be included in the next update for the double triggering.