Browse Source

use helper methods GetStyle / SetStyle.

pull/3849/head
Dan Walmsley 7 years ago
parent
commit
1ce8f4f6ba
  1. 16
      src/Windows/Avalonia.Win32/WindowImpl.cs

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

@ -254,8 +254,8 @@ namespace Avalonia.Win32
// Save current window state if not already fullscreen. // Save current window state if not already fullscreen.
if (!_fullScreen) if (!_fullScreen)
{ {
_savedWindowInfo.Style = (WindowStyles)GetWindowLong(_hwnd, (int)WindowLongParam.GWL_STYLE); _savedWindowInfo.Style = GetStyle();
_savedWindowInfo.ExStyle = (WindowStyles)GetWindowLong(_hwnd, (int)WindowLongParam.GWL_EXSTYLE); _savedWindowInfo.ExStyle = GetExtendedStyle();
GetWindowRect(_hwnd, out var windowRect); GetWindowRect(_hwnd, out var windowRect);
_savedWindowInfo.WindowRect = windowRect; _savedWindowInfo.WindowRect = windowRect;
} }
@ -265,12 +265,8 @@ namespace Avalonia.Win32
if (_fullScreen) if (_fullScreen)
{ {
// Set new window style and size. // Set new window style and size.
SetWindowLong(_hwnd, (int)WindowLongParam.GWL_STYLE, SetStyle(_savedWindowInfo.Style & ~(WindowStyles.WS_CAPTION | WindowStyles.WS_THICKFRAME));
(uint)(_savedWindowInfo.Style & ~(WindowStyles.WS_CAPTION | WindowStyles.WS_THICKFRAME))); SetExtendedStyle(_savedWindowInfo.ExStyle & ~(WindowStyles.WS_EX_DLGMODALFRAME | WindowStyles.WS_EX_WINDOWEDGE | WindowStyles.WS_EX_CLIENTEDGE | WindowStyles.WS_EX_STATICEDGE));
SetWindowLong(
_hwnd, (int)WindowLongParam.GWL_EXSTYLE,
(uint)(_savedWindowInfo.ExStyle & ~(WindowStyles.WS_EX_DLGMODALFRAME | WindowStyles.WS_EX_WINDOWEDGE |
WindowStyles.WS_EX_CLIENTEDGE | WindowStyles.WS_EX_STATICEDGE)));
// On expand, if we're given a window_rect, grow to it, otherwise do // On expand, if we're given a window_rect, grow to it, otherwise do
// not resize. // not resize.
@ -288,8 +284,8 @@ namespace Avalonia.Win32
// Reset original window style and size. The multiple window size/moves // Reset original window style and size. The multiple window size/moves
// here are ugly, but if SetWindowPos() doesn't redraw, the taskbar won't be // here are ugly, but if SetWindowPos() doesn't redraw, the taskbar won't be
// repainted. Better-looking methods welcome. // repainted. Better-looking methods welcome.
SetWindowLong(_hwnd, (int)WindowLongParam.GWL_STYLE, (uint)_savedWindowInfo.Style); SetStyle(_savedWindowInfo.Style);
SetWindowLong(_hwnd, (int)WindowLongParam.GWL_EXSTYLE, (uint)_savedWindowInfo.ExStyle); SetExtendedStyle(_savedWindowInfo.ExStyle);
// On restore, resize to the previous saved rect size. // On restore, resize to the previous saved rect size.
var new_rect = _savedWindowInfo.WindowRect.ToPixelRect(); var new_rect = _savedWindowInfo.WindowRect.ToPixelRect();

Loading…
Cancel
Save