win32: fix AppBringToFront when modal system dialog is visible

git-svn-id: trunk@51800 -
This commit is contained in:
ondrej 2016-03-02 08:00:06 +00:00
parent 9c843a9ea8
commit 2fc6fbf6fc

View File

@ -243,6 +243,12 @@ procedure TWin32WidgetSet.AppBringToFront;
var var
Window: HWND; Window: HWND;
begin begin
if Application.MainFormOnTaskBar and (Application.MainFormHandle<>0) then
Window := GetLastActivePopup(Application.MainFormHandle)
else
Window := GetLastActivePopup(AppHandle);
if not((Window <> 0) and IsWindowVisible(Window) and IsWindowEnabled(Window)) then
begin
if Assigned(Screen) and Assigned(Screen.ActiveCustomForm) and Screen.ActiveCustomForm.HandleAllocated then if Assigned(Screen) and Assigned(Screen.ActiveCustomForm) and Screen.ActiveCustomForm.HandleAllocated then
Window := Screen.ActiveCustomForm.Handle Window := Screen.ActiveCustomForm.Handle
else else
@ -250,6 +256,7 @@ begin
Window := Application.MainFormHandle Window := Application.MainFormHandle
else else
Window := FAppHandle; Window := FAppHandle;
end;
if (Window <> 0) and IsWindowVisible(Window) and IsWindowEnabled(Window) then if (Window <> 0) and IsWindowVisible(Window) and IsWindowEnabled(Window) then
Windows.SetForegroundWindow(Window); Windows.SetForegroundWindow(Window);
end; end;