mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-06-17 07:48:22 +02:00
win32: solve problem with wrong application Z-order (introduced in StayOnTop fix)
git-svn-id: trunk@12471 -
This commit is contained in:
parent
6fa6c7fd37
commit
0492763d06
@ -1142,7 +1142,12 @@ begin
|
|||||||
begin // deactivated
|
begin // deactivated
|
||||||
//WriteLn('Remove');
|
//WriteLn('Remove');
|
||||||
RemoveStayOnTopFlags(Window);
|
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);
|
0, 0, 0, 0, SWP_NOMOVE or SWP_NOSIZE or SWP_NOACTIVATE);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
@ -1117,12 +1117,13 @@ var
|
|||||||
AStyle: DWord;
|
AStyle: DWord;
|
||||||
StayOnTopWindowsInfo: PStayOnTopWindowsInfo absolute Param;
|
StayOnTopWindowsInfo: PStayOnTopWindowsInfo absolute Param;
|
||||||
begin
|
begin
|
||||||
Result := Handle <> StayOnTopWindowsInfo^.AppWindow;
|
Result := True;
|
||||||
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
|
||||||
StayOnTopWindowsInfo^.StayOnTopList.Add(Pointer(Handle));
|
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;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -1131,6 +1132,7 @@ var
|
|||||||
StayOnTopWindowsInfo: PStayOnTopWindowsInfo;
|
StayOnTopWindowsInfo: PStayOnTopWindowsInfo;
|
||||||
WindowInfo: PWindowInfo;
|
WindowInfo: PWindowInfo;
|
||||||
begin
|
begin
|
||||||
|
// WriteLn('RemoveStayOnTopFlags 1');
|
||||||
if InRemoveStayOnTopFlags = 0 then
|
if InRemoveStayOnTopFlags = 0 then
|
||||||
begin
|
begin
|
||||||
New(StayOnTopWindowsInfo);
|
New(StayOnTopWindowsInfo);
|
||||||
@ -1143,6 +1145,7 @@ begin
|
|||||||
Dispose(StayOnTopWindowsInfo);
|
Dispose(StayOnTopWindowsInfo);
|
||||||
end;
|
end;
|
||||||
inc(InRemoveStayOnTopFlags);
|
inc(InRemoveStayOnTopFlags);
|
||||||
|
// WriteLn('RemoveStayOnTopFlags 2');
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure RestoreStayOnTopFlags(Window: HWND);
|
procedure RestoreStayOnTopFlags(Window: HWND);
|
||||||
@ -1150,6 +1153,7 @@ var
|
|||||||
WindowInfo: PWindowInfo;
|
WindowInfo: PWindowInfo;
|
||||||
I: integer;
|
I: integer;
|
||||||
begin
|
begin
|
||||||
|
// WriteLn('RestoreStayOnTopFlags 1');
|
||||||
if InRemoveStayOnTopFlags = 1 then
|
if InRemoveStayOnTopFlags = 1 then
|
||||||
begin
|
begin
|
||||||
WindowInfo := GetWindowInfo(Window);
|
WindowInfo := GetWindowInfo(Window);
|
||||||
@ -1157,12 +1161,14 @@ begin
|
|||||||
begin
|
begin
|
||||||
for I := 0 to WindowInfo^.StayOnTopList.Count - 1 do
|
for I := 0 to WindowInfo^.StayOnTopList.Count - 1 do
|
||||||
SetWindowPos(HWND(WindowInfo^.StayOnTopList.Items[I]),
|
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);
|
FreeAndNil(WindowInfo^.StayOnTopList);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
if InRemoveStayOnTopFlags > 0 then
|
if InRemoveStayOnTopFlags > 0 then
|
||||||
dec(InRemoveStayOnTopFlags);
|
dec(InRemoveStayOnTopFlags);
|
||||||
|
// WriteLn('RestoreStayOnTopFlags 2');
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user