From 1d0b6ba4cb22827fba71ef99b3ee7734a3c442fd Mon Sep 17 00:00:00 2001 From: batzen Date: Fri, 18 Sep 2015 01:35:02 +0200 Subject: [PATCH] Fixes #170, #80 and #159 by not reacting to WM_STYLECHANGED but WM_SIZE instead --- Fluent/Internal/WindowSizing.cs | 17 +++++++---------- Fluent/Metro/Native/Constants.cs | 1 + 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/Fluent/Internal/WindowSizing.cs b/Fluent/Internal/WindowSizing.cs index 362bf9a60..757246fa2 100644 --- a/Fluent/Internal/WindowSizing.cs +++ b/Fluent/Internal/WindowSizing.cs @@ -75,8 +75,13 @@ private IntPtr HwndHook(IntPtr hWnd, int message, IntPtr wParam, IntPtr lParam, switch (message) { - case Constants.WM_STYLECHANGED: - this.FixWindowChromeBugForFreezedMaximizedWindow(); + case Constants.WM_SIZE: + // When window is maximized and was not responding, windows issues another WM_SIZE when window is responding again so we need to shift the window position back and forth + // Fixes #80, #159 and #170 + if (this.GetWindowPlacement().showCmd == 3) + { + this.FixWindowChromeBugForMaximizedWindow(); + } break; case Constants.WM_GETMINMAXINFO: @@ -96,14 +101,6 @@ private WINDOWPLACEMENT GetWindowPlacement() #region Fixes - private void FixWindowChromeBugForFreezedMaximizedWindow() - { - if (this.GetWindowPlacement().showCmd == 3) - { - this.FixWindowChromeBugForMaximizedWindow(); - } - } - private void FixMinMaxInfo(IntPtr hWnd, IntPtr lParam, out bool handled) { if (this.GetWindowPlacement().showCmd == 3) diff --git a/Fluent/Metro/Native/Constants.cs b/Fluent/Metro/Native/Constants.cs index 5f34a6069..69f90b2f8 100644 --- a/Fluent/Metro/Native/Constants.cs +++ b/Fluent/Metro/Native/Constants.cs @@ -13,6 +13,7 @@ internal static class Constants public const int WM_STYLECHANGED = 0x7d; public const int WM_CREATE = 0x0001; public const int WM_NCHITTEST = 0x84; + public const int WM_SIZE = 0x0005; public const long WS_MAXIMIZE = 0x01000000;