Browse Source

Use existing OffscreenParentWindow to hide taskbar icon.

pull/5715/head
Steven Kirk 6 years ago
parent
commit
a1d6531881
  1. 16
      src/Windows/Avalonia.Win32/WindowImpl.cs

16
src/Windows/Avalonia.Win32/WindowImpl.cs

@ -85,7 +85,7 @@ namespace Avalonia.Win32
private ExtendClientAreaChromeHints _extendChromeHints = ExtendClientAreaChromeHints.Default; private ExtendClientAreaChromeHints _extendChromeHints = ExtendClientAreaChromeHints.Default;
private bool _isCloseRequested; private bool _isCloseRequested;
private bool _shown; private bool _shown;
private WindowImpl _hiddenWindow; private bool _hiddenWindowIsParent;
public WindowImpl() public WindowImpl()
{ {
@ -527,7 +527,6 @@ namespace Avalonia.Win32
} }
_framebuffer.Dispose(); _framebuffer.Dispose();
_hiddenWindow?.Dispose();
} }
public void Invalidate(Rect rect) public void Invalidate(Rect rect)
@ -757,11 +756,6 @@ namespace Avalonia.Win32
} }
} }
private WindowImpl GetOrCreateHiddenWindow()
{
return _hiddenWindow ??= new WindowImpl();
}
private void CreateDropTarget() private void CreateDropTarget()
{ {
var odt = new OleDropTarget(this, _owner); var odt = new OleDropTarget(this, _owner);
@ -1102,7 +1096,7 @@ namespace Avalonia.Win32
{ {
exStyle |= WindowStyles.WS_EX_APPWINDOW; exStyle |= WindowStyles.WS_EX_APPWINDOW;
if (_hiddenWindow is object && _parent == _hiddenWindow) if (_hiddenWindowIsParent)
{ {
// Can't enable the taskbar icon by clearing the parent window unless the window // Can't enable the taskbar icon by clearing the parent window unless the window
// is hidden. Hide the window and show it again with the same activation state // is hidden. Hide the window and show it again with the same activation state
@ -1118,13 +1112,15 @@ namespace Avalonia.Win32
if (shown) if (shown)
Show(activated); Show(activated);
} }
} }
else else
{ {
// To hide a non-owned window's taskbar icon we need to parent it to a hidden window. // To hide a non-owned window's taskbar icon we need to parent it to a hidden window.
if (_parent is null) if (_parent is null)
SetParent(GetOrCreateHiddenWindow()); {
SetWindowLongPtr(_hwnd, (int)WindowLongParam.GWL_HWNDPARENT, OffscreenParentWindow.Handle);
_hiddenWindowIsParent = true;
}
exStyle &= ~WindowStyles.WS_EX_APPWINDOW; exStyle &= ~WindowStyles.WS_EX_APPWINDOW;
} }

Loading…
Cancel
Save