@furious programming powinno ale nie zawsze tak jest - zaczyna się to rozjeżdżać jeśli masz co najmniej dwie modalne formy - wtedy ta druga potrafi się schować pod aplikacją. Odpowiedzialny za to jest menadżer okien z XPka i wyższych (ten, który wyłapuje zawieszone okna). Można go wyłączyć dla naszej aplikacji przez
procedure DisableWindowsGhosting;
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;
i w oknach, które są modalne
unit ModalForm;
interface
uses
Forms, Controls;
type
TModalForm = class(TForm)
protected
procedure CreateParams(var params: TCreateParams); override;
end;
implementation
uses
Windows;
{ TModalForm }
procedure TModalForm.CreateParams(var params: TCreateParams);
begin
inherited;
if Screen.ActiveForm <> nil then
params.WndParent := Screen.ActiveForm.Handle
else if Application.MainForm <> nil then
params.WndParent := Application.MainForm.Handle
else
params.WndParent := Application.Handle;
if (params.WndParent <> 0) and (IsIconic(params.WndParent)
or not IsWindowVisible(params.WndParent)
or not IsWindowEnabled(params.WndParent)) then
params.WndParent := 0;
if params.WndParent = 0 then
params.WndParent := Application.Handle;
end;
end.
W D7 niweluje problem z oknami modalnymi na windowsach od XP do 8.1