[Mwinapi-commits] SF.net SVN: mwinapi:[123] trunk/ManagedWinapi/Windows/SystemWindow.cs
Status: Beta
Brought to you by:
schierlm
From: <zi...@us...> - 2014-11-26 10:23:34
|
Revision: 123 http://sourceforge.net/p/mwinapi/code/123 Author: ziewer Date: 2014-11-26 10:23:27 +0000 (Wed, 26 Nov 2014) Log Message: ----------- fixed SystemWindow.Rectangle for maximized windows with Windows Aero Modified Paths: -------------- trunk/ManagedWinapi/Windows/SystemWindow.cs Modified: trunk/ManagedWinapi/Windows/SystemWindow.cs =================================================================== --- trunk/ManagedWinapi/Windows/SystemWindow.cs 2014-11-25 17:35:37 UTC (rev 122) +++ trunk/ManagedWinapi/Windows/SystemWindow.cs 2014-11-26 10:23:27 UTC (rev 123) @@ -755,6 +755,24 @@ { RECT r = new RECT(); GetWindowRect(_hwnd, out r); + + // GetWindowRect returns wrong values for maximized windows when using Windows Aero desktop. + // Reduce bounds by negative padding of "glass" pixels for maximized windows. + if ((Style & WindowStyleFlags.MAXIMIZE) > 0) + { + // check whether top or left is negative + // check both to support dual screen setup where bounds.Left might be larger than 0 on right screen + int glass = Math.Min(r.Left, r.Top); + if (glass < 0) + { + // remove glass pixels from rectangle + r.Left -= glass; + r.Top -= glass; + r.Right += glass; + r.Bottom += glass; + } + } + return r; } } @@ -1087,8 +1105,7 @@ /// </summary> public void Highlight() { - RECT rect; - GetWindowRect(_hwnd, out rect); + RECT rect = Rectangle; using (WindowDeviceContext windowDC = GetDeviceContext(false)) { using (Graphics g = windowDC.CreateGraphics()) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |