Questions from the past – Invisible Modal Window

Delphi 2005 and older does suffer from one annoying problem – once in the while your modal dialog will be stuck behind of window it suppose to be modal to.

It is very “funny” when someone trying to click on main application window and it does not get focus (most likely you are using Windows XP). Magic wand? yes! Alt+TAB to switch off the application and then Alt+TAB to come back and reactivate it. Ah! you have modal dialog sitting behind, which off cause require you to click a button and keeping everything else waiting. Try to explain this to some of your customers… sometimes you might see very funny faces.

Inconvenience? yes. Is there a way around it? yes. It was fixed since Delphi 2006. Upgrade!!!!
Is not justifiable? Then call few lines of code on start-up of your application.

procedure DisableProcessWindowsGhosting;
var
  DisableProcessWindowsGhostingProc: procedure;
begin
  DisableProcessWindowsGhostingProc := GetProcAddress(
    GetModuleHandle('user32.dll'),
    'DisableProcessWindowsGhosting');
  if Assigned(DisableProcessWindowsGhostingProc) then
    DisableProcessWindowsGhostingProc;
end;

More details are provided in this QC entry. Enjoy.

This entry was posted in Delphi. Bookmark the permalink.

Leave a Reply