win32: hide/restore popup windows on application.minimize/restore (issue #0016577)

git-svn-id: trunk@29955 -
This commit is contained in:
paul 2011-03-21 07:53:51 +00:00
parent 9487b41cc5
commit 5445a84dc4
2 changed files with 55 additions and 0 deletions

View File

@ -803,6 +803,7 @@ var
if (Window = Win32WidgetSet.AppHandle) and not Application.MainFormOnTaskBar then
begin
HidePopups(Win32WidgetSet.AppHandle);
if Assigned(Application.MainForm) then
begin
Windows.SetWindowPos(Window, HWND_TOP,
@ -838,6 +839,7 @@ var
begin
if Application.MainForm.HandleObjectShouldBeVisible then
Windows.ShowWindow(Application.MainFormHandle, SW_SHOWNA);
RestorePopups;
end;
Application.IntfAppRestore;
end

View File

@ -104,6 +104,8 @@ function GetWin32WindowInfo(Window: HWND): PWin32WindowInfo;
procedure RemoveStayOnTopFlags(Window: HWND; ASystemTopAlso: Boolean = False);
procedure RestoreStayOnTopFlags(Window: HWND);
procedure HidePopups(AppHandle: HWND);
procedure RestorePopups;
procedure AddToChangedMenus(Window: HWnd);
procedure RedrawMenus;
@ -137,6 +139,12 @@ type
StayOnTopList: TList;
end;
PPopupOwnersWindowInfo = ^TPopupOwnersWindowInfo;
TPopupOwnersWindowInfo = record
AppHandle: HWND;
OwnersList: TList;
end;
TWindowsVersion = (
wvUnknown,
wv95,
@ -176,6 +184,7 @@ uses
var
InRemoveStayOnTopFlags: Integer = 0;
PopupOwnersList: TList = nil;
{------------------------------------------------------------------------------
function: WM_To_String
Params: WM_Message - a WinDows message
@ -1021,6 +1030,49 @@ begin
// WriteLn('RestoreStayOnTopFlags 2');
end;
function EnumHidePopups(Handle: HWND; Param: LPARAM): WINBOOL; stdcall;
var
Owner: HWND;
begin
Owner := GetWindow(Handle, GW_OWNER);
if (Owner <> 0) and (Owner <> PPopupOwnersWindowInfo(Param)^.AppHandle) then
PPopupOwnersWindowInfo(Param)^.OwnersList.Add(Pointer(Owner));
Result := True;
end;
procedure HidePopups(AppHandle: HWND);
var
i: Integer;
Info: PPopupOwnersWindowInfo;
begin
if not Assigned(PopupOwnersList) then
begin
PopupOwnersList := TList.Create;
New(Info);
try
Info^.AppHandle := AppHandle;
Info^.OwnersList := PopupOwnersList;
EnumThreadWindows(GetWindowThreadProcessId(Application.MainFormHandle, nil),
@EnumHidePopups, LPARAM(Info));
for i := 0 to PopupOwnersList.Count - 1 do
ShowOwnedPopups(HWND(PopupOwnersList[i]), False);
finally
Dispose(Info);
end;
end;
end;
procedure RestorePopups;
var
i: Integer;
begin
if Assigned(PopupOwnersList) then
begin
for i := 0 to PopupOwnersList.Count - 1 do
ShowOwnedPopups(HWND(PopupOwnersList[i]), True);
FreeAndNil(PopupOwnersList);
end;
end;
{-------------------------------------------------------------------------------
procedure AddToChangedMenus(Window: HWnd);
@ -1713,5 +1765,6 @@ finalization
Windows.GlobalDeleteAtom(WindowInfoAtom);
WindowInfoAtom := 0;
ChangedMenus.Free;
FreeAndNil(PopupOwnersList);
end.