Browse Source

Attempt of fixing more child window operations.

pull/4928/head
Dariusz Komosinski 6 years ago
parent
commit
134f916262
  1. 6
      src/Windows/Avalonia.Win32/Interop/UnmanagedMethods.cs
  2. 12
      src/Windows/Avalonia.Win32/WindowImpl.AppWndProc.cs

6
src/Windows/Avalonia.Win32/Interop/UnmanagedMethods.cs

@ -1017,6 +1017,9 @@ namespace Avalonia.Win32.Interop
[DllImport("user32.dll")]
public static extern bool ValidateRect(IntPtr hWnd, IntPtr lpRect);
[DllImport("user32.dll")]
public static extern bool IsWindow(IntPtr hWnd);
[DllImport("user32.dll")]
public static extern bool IsWindowEnabled(IntPtr hWnd);
@ -1050,6 +1053,9 @@ namespace Avalonia.Win32.Interop
[DllImport("user32.dll")]
public static extern bool ScreenToClient(IntPtr hWnd, ref POINT lpPoint);
[DllImport("user32.dll", SetLastError = true)]
public static extern IntPtr GetActiveWindow();
[DllImport("user32.dll", SetLastError = true)]
public static extern IntPtr SetActiveWindow(IntPtr hWnd);

12
src/Windows/Avalonia.Win32/WindowImpl.AppWndProc.cs

@ -65,7 +65,17 @@ namespace Avalonia.Win32
return IntPtr.Zero;
}
_parent?.SetEnabled(true);
if (_parent != null && IsWindow(_parent._hwnd))
{
var wasActive = GetActiveWindow() == _hwnd;
_parent.SetEnabled(true);
if (wasActive)
{
SetActiveWindow(_parent._hwnd);
}
}
break;
}

Loading…
Cancel
Save