Updates Win32 RemoveStayOnTop

git-svn-id: trunk@25536 -
This commit is contained in:
sekelsenmat 2010-05-20 11:07:03 +00:00
parent c86392f301
commit a72bba258d
2 changed files with 15 additions and 10 deletions

View File

@ -511,7 +511,7 @@ end;
function TWin32WidgetSet.AppRemoveStayOnTopFlags(const ASystemTopAlso: Boolean = False): Boolean; function TWin32WidgetSet.AppRemoveStayOnTopFlags(const ASystemTopAlso: Boolean = False): Boolean;
begin begin
RemoveStayOnTopFlags(AppHandle); RemoveStayOnTopFlags(AppHandle, ASystemTopAlso);
Result := True; Result := True;
end; end;

View File

@ -109,7 +109,7 @@ function AllocWindowInfo(Window: HWND): PWin32WindowInfo;
function DisposeWindowInfo(Window: HWND): boolean; function DisposeWindowInfo(Window: HWND): boolean;
function GetWin32WindowInfo(Window: HWND): PWin32WindowInfo; function GetWin32WindowInfo(Window: HWND): PWin32WindowInfo;
procedure RemoveStayOnTopFlags(Window: HWND); procedure RemoveStayOnTopFlags(Window: HWND; ASystemTopAlso: Boolean = False);
procedure RestoreStayOnTopFlags(Window: HWND); procedure RestoreStayOnTopFlags(Window: HWND);
procedure AddToChangedMenus(Window: HWnd); procedure AddToChangedMenus(Window: HWnd);
@ -142,6 +142,7 @@ type
PStayOnTopWindowsInfo = ^TStayOnTopWindowsInfo; PStayOnTopWindowsInfo = ^TStayOnTopWindowsInfo;
TStayOnTopWindowsInfo = record TStayOnTopWindowsInfo = record
AppWindow: HWND; AppWindow: HWND;
SystemTopAlso: Boolean;
StayOnTopList: TList; StayOnTopList: TList;
end; end;
@ -1079,14 +1080,17 @@ begin
AStyle := GetWindowLong(Handle, GWL_EXSTYLE); AStyle := GetWindowLong(Handle, GWL_EXSTYLE);
if (AStyle and WS_EX_TOPMOST) <> 0 then // if stay on top then if (AStyle and WS_EX_TOPMOST) <> 0 then // if stay on top then
begin begin
// Don't remove system-wide stay on top // Don't remove system-wide stay on top, unless desired
lWindowInfo := GetWin32WindowInfo(Handle); if not StayOnTopWindowsInfo^.SystemTopAlso then
if (lWindowInfo <> nil) then
begin begin
lWinControl := lWindowInfo^.WinControl; lWindowInfo := GetWin32WindowInfo(Handle);
if (lWinControl <> nil) and (lWinControl is TCustomForm) if (lWindowInfo <> nil) then
and (TCustomForm(lWinControl).FormStyle = fsSystemStayOnTop) then begin
Exit; lWinControl := lWindowInfo^.WinControl;
if (lWinControl <> nil) and (lWinControl is TCustomForm)
and (TCustomForm(lWinControl).FormStyle = fsSystemStayOnTop) then
Exit;
end;
end; end;
StayOnTopWindowsInfo^.StayOnTopList.Add(Pointer(Handle)); StayOnTopWindowsInfo^.StayOnTopList.Add(Pointer(Handle));
@ -1095,7 +1099,7 @@ begin
end; end;
end; end;
procedure RemoveStayOnTopFlags(Window: HWND); procedure RemoveStayOnTopFlags(Window: HWND; ASystemTopAlso: Boolean = False);
var var
StayOnTopWindowsInfo: PStayOnTopWindowsInfo; StayOnTopWindowsInfo: PStayOnTopWindowsInfo;
WindowInfo: PWin32WindowInfo; WindowInfo: PWin32WindowInfo;
@ -1105,6 +1109,7 @@ begin
begin begin
New(StayOnTopWindowsInfo); New(StayOnTopWindowsInfo);
StayOnTopWindowsInfo^.AppWindow := Window; StayOnTopWindowsInfo^.AppWindow := Window;
StayOnTopWindowsInfo^.SystemTopAlso := ASystemTopAlso;
StayOnTopWindowsInfo^.StayOnTopList := TList.Create; StayOnTopWindowsInfo^.StayOnTopList := TList.Create;
WindowInfo := GetWin32WindowInfo(Window); WindowInfo := GetWin32WindowInfo(Window);
WindowInfo^.StayOnTopList := StayOnTopWindowsInfo^.StayOnTopList; WindowInfo^.StayOnTopList := StayOnTopWindowsInfo^.StayOnTopList;