win32: solve problem with wrong application Z-order (introduced in StayOnTop fix)

git-svn-id: trunk@12471 -
This commit is contained in:
paul 2007-10-15 06:18:03 +00:00
parent 6fa6c7fd37
commit 0492763d06
2 changed files with 15 additions and 4 deletions

View File

@ -1142,7 +1142,12 @@ begin
begin // deactivated
//WriteLn('Remove');
RemoveStayOnTopFlags(Window);
Windows.SetWindowPos(TWin32WidgetSet(WidgetSet).AppHandle, HWND_BOTTOM,
// this is workarond. After RemoveStayOnTopFlags previously stay on top windows are
// stil on top. So if you switch application they will be on top before second switch
TargetWindow := GetNextWindow(TWin32WidgetSet(WidgetSet).AppHandle, GW_HWNDNEXT);
if TargetWindow = 0 then
TargetWindow := HWND_BOTTOM;
Windows.SetWindowPos(TWin32WidgetSet(WidgetSet).AppHandle, TargetWindow,
0, 0, 0, 0, SWP_NOMOVE or SWP_NOSIZE or SWP_NOACTIVATE);
end;

View File

@ -1117,12 +1117,13 @@ var
AStyle: DWord;
StayOnTopWindowsInfo: PStayOnTopWindowsInfo absolute Param;
begin
Result := Handle <> StayOnTopWindowsInfo^.AppWindow;
Result := True;
AStyle := GetWindowLong(Handle, GWL_EXSTYLE);
if (AStyle and WS_EX_TOPMOST) <> 0 then // if stay on top then
begin
StayOnTopWindowsInfo^.StayOnTopList.Add(Pointer(Handle));
SetWindowPos(Handle, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE or SWP_NOSIZE or SWP_NOACTIVATE);
SetWindowPos(Handle, HWND_NOTOPMOST, 0, 0, 0, 0,
SWP_NOMOVE or SWP_NOSIZE or SWP_NOACTIVATE or SWP_NOOWNERZORDER or SWP_NOSENDCHANGING);
end;
end;
@ -1131,6 +1132,7 @@ var
StayOnTopWindowsInfo: PStayOnTopWindowsInfo;
WindowInfo: PWindowInfo;
begin
// WriteLn('RemoveStayOnTopFlags 1');
if InRemoveStayOnTopFlags = 0 then
begin
New(StayOnTopWindowsInfo);
@ -1143,6 +1145,7 @@ begin
Dispose(StayOnTopWindowsInfo);
end;
inc(InRemoveStayOnTopFlags);
// WriteLn('RemoveStayOnTopFlags 2');
end;
procedure RestoreStayOnTopFlags(Window: HWND);
@ -1150,6 +1153,7 @@ var
WindowInfo: PWindowInfo;
I: integer;
begin
// WriteLn('RestoreStayOnTopFlags 1');
if InRemoveStayOnTopFlags = 1 then
begin
WindowInfo := GetWindowInfo(Window);
@ -1157,12 +1161,14 @@ begin
begin
for I := 0 to WindowInfo^.StayOnTopList.Count - 1 do
SetWindowPos(HWND(WindowInfo^.StayOnTopList.Items[I]),
HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE or SWP_NOSIZE or SWP_NOACTIVATE);
HWND_TOPMOST, 0, 0, 0, 0,
SWP_NOMOVE or SWP_NOSIZE or SWP_NOACTIVATE or SWP_NOOWNERZORDER or SWP_NOSENDCHANGING);
FreeAndNil(WindowInfo^.StayOnTopList);
end;
end;
if InRemoveStayOnTopFlags > 0 then
dec(InRemoveStayOnTopFlags);
// WriteLn('RestoreStayOnTopFlags 2');
end;