diff --git a/Windows/Perspex.Win32/WindowImpl.cs b/Windows/Perspex.Win32/WindowImpl.cs index 3af2c0667e..e850afb3b4 100644 --- a/Windows/Perspex.Win32/WindowImpl.cs +++ b/Windows/Perspex.Win32/WindowImpl.cs @@ -185,12 +185,16 @@ namespace Perspex.Win32 break; case UnmanagedMethods.WindowsMessage.WM_PAINT: - UnmanagedMethods.RECT r; UnmanagedMethods.PAINTSTRUCT ps; - UnmanagedMethods.GetUpdateRect(this.hwnd, out r, false); - UnmanagedMethods.BeginPaint(this.hwnd, out ps); - this.Paint(new Rect(r.left, r.top, r.right - r.left, r.bottom - r.top), this.Handle); - UnmanagedMethods.EndPaint(this.hwnd, ref ps); + + if (UnmanagedMethods.BeginPaint(this.hwnd, out ps) != IntPtr.Zero) + { + UnmanagedMethods.RECT r; + UnmanagedMethods.GetUpdateRect(this.hwnd, out r, false); + this.Paint(new Rect(r.left, r.top, r.right - r.left, r.bottom - r.top), this.Handle); + UnmanagedMethods.EndPaint(this.hwnd, ref ps); + } + return IntPtr.Zero; case UnmanagedMethods.WindowsMessage.WM_SIZE: