It might be a bug, but then a bug in the OS.
In a Dutch pascal usergroup forum, there is also a question on using the OnExit event of a control. It seems if you switch focus to another form or something similar in the OnExit event windows seems to loose track of where the focus is.
So if you do
procedure TForm1.Edit1Exit(Sender: TObject);
begin
Form2 := TForm2.Create( nil );
try
Form2.ShowModal;
finally
Form2.Free;
end;
end;
you get some strange results. Sometimes you need to click in the next control to get it to work again, although you see the cursos in it.
So what I usually advise to do is this:
When you do some checking on the contents of an edit in the on exit event do not show to a diffirent form when the contents is OK. If the contents is not OK and you want to show another form or a message put the focus back to the control you left. So using the code above, do it like this:
procedure TForm1.Edit1Exit(Sender: TObject);
begin
if not IsOK(TEdit(Sender).Text) then begin
Form2 := TForm2.Create( nil );
try
Form2.ShowModal;
finally
Form2.Free;
end;
TEdit(Sender).SetFocus;
end;
end;