Delphi – Closing a secondary delphi form causes the main form to lose focus

delphidelphi-2009vclwinapi

When showing a secondary form from the main form and from the second form showing a third form and then closing both forms will cause the main form to lose focus.

Using Delphi 2009 with XP SP3

Here are my steps for reproducing the problem:

  1. Create a new VCL forms applications
  2. Drag a button onto the created form
  3. In the click handler create a new TForm1 and show it

Run the program. Click the button to show a second form. Click the button on the second form to create a third form. When closing both new forms the main form will lose its focus.

This is my code in the button click event handler:

// Using Self does not change the results
with TForm1.Create(nil) do
    show;

Is there any way to stop my main form from losing focus?

Best Answer

After upgrading my Delphi installation from version 12.0.3170.16989 (no updates) to version 12.0.3420.21218 (update 3 & 4) I could not reproduce the problem anymore.

Seems like it was a bug that was fixed in the update.

Related Topic