Newly created modal window loses focus and become inacessible in Windows Vista

Take a look at the PopupParent property. You may want to set it explicitly for your modal form prior to the ShowModal call. When PopupParent is nil (default) VCL behaves a bit differently depending on the value of the related PopupMode property.

If you set the modal form's PopupParent to the form that's active just before you call ShowModal, that may help.


The issue you have started happening when Windows XP introduced the concept of window ghosting. Due to the unusual architecture Delphi uses (all forms are children of a hidden window — TApplication) many Delphi applications experience the same problem.

One way to quickly solve it is to disable window ghosting when initializing the application:

var 
  User32: HMODULE; 
  DisableProcessWindowsGhosting: TProcedure; 
begin 
  User32 := GetModuleHandle('USER32'); 
  if User32 <> 0 then 
  begin 
    DisableProcessWindowsGhosting := GetProcAddress(User32, 'DisableProcessWindowsGhosting'); 
    if Assigned(DisableProcessWindowsGhosting) then 
      DisableProcessWindowsGhosting; 
  end; 
end;

Another possible (more elegant though laborious) solution is to normalize your Delphi application.

A third option would be switching to Delphi 2006 (Delphi 10.0).

Besides the issue you're reporting Delphi's architecture introduces more oddities, among them the different task bar menu and the inability to flash.