Browse Source

update documentation and fix bug when

system decorations are restored so that CanResize is obeyed.
pull/1574/head
Dan Walmsley 8 years ago
parent
commit
865a866388
  1. 4
      src/Avalonia.Controls/Window.cs
  2. 35
      src/Windows/Avalonia.Win32/WindowImpl.cs

4
src/Avalonia.Controls/Window.cs

@ -214,7 +214,9 @@ namespace Avalonia.Controls
}
/// <summary>
/// Enables or disables resizing of the window
/// Enables or disables resizing of the window.
/// Note that if <see cref="HasSystemDecorations"/> is set to False then this property
/// has no effect and should be treated as a recommendation for the user setting HasSystemDecorations.
/// </summary>
public bool CanResize
{

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

@ -287,6 +287,21 @@ namespace Avalonia.Win32
UnmanagedMethods.SetWindowPosFlags.SWP_NOZORDER | UnmanagedMethods.SetWindowPosFlags.SWP_NOACTIVATE);
_decorated = value;
if(_decorated)
{
if (_resizable)
{
// If we switch decorations back on we need to restore WS_SizeFrame.
_resizable = false;
CanResize(true);
}
else
{
_resizable = true;
CanResize(false);
}
}
}
public void Invalidate(Rect rect)
@ -857,14 +872,18 @@ namespace Avalonia.Win32
return;
}
var style = (UnmanagedMethods.WindowStyles)UnmanagedMethods.GetWindowLong(_hwnd, (int)UnmanagedMethods.WindowLongParam.GWL_STYLE);
if (value)
style |= UnmanagedMethods.WindowStyles.WS_SIZEFRAME;
else
style &= ~(UnmanagedMethods.WindowStyles.WS_SIZEFRAME);
UnmanagedMethods.SetWindowLong(_hwnd, (int)UnmanagedMethods.WindowLongParam.GWL_STYLE, (uint)style);
if (_decorated)
{
var style = (UnmanagedMethods.WindowStyles)UnmanagedMethods.GetWindowLong(_hwnd, (int)UnmanagedMethods.WindowLongParam.GWL_STYLE);
if (value)
style |= UnmanagedMethods.WindowStyles.WS_SIZEFRAME;
else
style &= ~(UnmanagedMethods.WindowStyles.WS_SIZEFRAME);
UnmanagedMethods.SetWindowLong(_hwnd, (int)UnmanagedMethods.WindowLongParam.GWL_STYLE, (uint)style);
}
_resizable = value;
}
}

Loading…
Cancel
Save