Browse Source

Revert "Merge pull request #3221 from mstr2/undecorated-window"

This reverts commit a3712ed4c2, reversing
changes made to edbd75cc1f.
pull/3250/head
Dan Walmsley 7 years ago
parent
commit
3f95e7676e
  1. 3
      src/Windows/Avalonia.Win32/Interop/UnmanagedMethods.cs
  2. 23
      src/Windows/Avalonia.Win32/WindowImpl.cs

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

@ -921,9 +921,6 @@ namespace Avalonia.Win32.Interop
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Unicode, EntryPoint = "SetWindowTextW")] [DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Unicode, EntryPoint = "SetWindowTextW")]
public static extern bool SetWindowText(IntPtr hwnd, string lpString); public static extern bool SetWindowText(IntPtr hwnd, string lpString);
[DllImport("uxtheme.dll", SetLastError = true, CharSet = CharSet.Unicode)]
public static extern HRESULT SetWindowTheme(IntPtr hwnd, string subAppName, string subIdList);
public enum ClassLongIndex : int public enum ClassLongIndex : int
{ {

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

@ -968,20 +968,26 @@ namespace Avalonia.Win32
{ {
var oldDecorated = _decorated; var oldDecorated = _decorated;
var oldThickness = BorderThickness;
change(); change();
var style = (WindowStyles)GetWindowLong(_hwnd, (int)WindowLongParam.GWL_STYLE); var style = (WindowStyles)GetWindowLong(_hwnd, (int)WindowLongParam.GWL_STYLE);
const WindowStyles controlledFlags = WindowStyles.WS_OVERLAPPEDWINDOW;
style = style | controlledFlags ^ controlledFlags;
style |= WindowStyles.WS_OVERLAPPEDWINDOW; style |= WindowStyles.WS_OVERLAPPEDWINDOW;
if (!_decorated) if (!_decorated)
{ {
style &= ~WindowStyles.WS_SYSMENU; style ^= (WindowStyles.WS_CAPTION | WindowStyles.WS_SYSMENU);
} }
if (!_resizable) if (!_resizable)
{ {
style &= ~WindowStyles.WS_SIZEFRAME; style ^= (WindowStyles.WS_SIZEFRAME);
} }
GetClientRect(_hwnd, out var oldClientRect); GetClientRect(_hwnd, out var oldClientRect);
@ -989,6 +995,7 @@ namespace Avalonia.Win32
ClientToScreen(_hwnd, ref oldClientRectOrigin); ClientToScreen(_hwnd, ref oldClientRectOrigin);
oldClientRect.Offset(oldClientRectOrigin); oldClientRect.Offset(oldClientRectOrigin);
SetWindowLong(_hwnd, (int)WindowLongParam.GWL_STYLE, (uint)style); SetWindowLong(_hwnd, (int)WindowLongParam.GWL_STYLE, (uint)style);
UnmanagedMethods.GetWindowRect(_hwnd, out var windowRect); UnmanagedMethods.GetWindowRect(_hwnd, out var windowRect);
@ -997,16 +1004,8 @@ namespace Avalonia.Win32
{ {
var newRect = oldClientRect; var newRect = oldClientRect;
if (_decorated) if (_decorated)
{ AdjustWindowRectEx(ref newRect, (uint)style, false,
SetWindowTheme(_hwnd, null, null); GetWindowLong(_hwnd, (int)WindowLongParam.GWL_EXSTYLE));
AdjustWindowRectEx(
ref newRect, (uint)style, false, GetWindowLong(_hwnd, (int)WindowLongParam.GWL_EXSTYLE));
}
else
{
SetWindowTheme(_hwnd, "", "");
}
SetWindowPos(_hwnd, IntPtr.Zero, newRect.left, newRect.top, newRect.Width, newRect.Height, SetWindowPos(_hwnd, IntPtr.Zero, newRect.left, newRect.top, newRect.Width, newRect.Height,
SetWindowPosFlags.SWP_NOZORDER | SetWindowPosFlags.SWP_NOACTIVATE | SetWindowPosFlags.SWP_FRAMECHANGED); SetWindowPosFlags.SWP_NOZORDER | SetWindowPosFlags.SWP_NOACTIVATE | SetWindowPosFlags.SWP_FRAMECHANGED);
frameUpdated = true; frameUpdated = true;

Loading…
Cancel
Save