Thread: [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. |
From: <zi...@us...> - 2014-11-26 10:31:39
|
Revision: 124 http://sourceforge.net/p/mwinapi/code/124 Author: ziewer Date: 2014-11-26 10:31:31 +0000 (Wed, 26 Nov 2014) Log Message: ----------- fixed SystemWindow.Rectangle for maximized windows with Windows Aero Glass comment added - see http://social.msdn.microsoft.com/Forums/en-US/windowsuidevelopment/thread/6c1c67a9-5548-4e9b-989f-c7dbac0b1375/ Modified Paths: -------------- trunk/ManagedWinapi/Windows/SystemWindow.cs Modified: trunk/ManagedWinapi/Windows/SystemWindow.cs =================================================================== --- trunk/ManagedWinapi/Windows/SystemWindow.cs 2014-11-26 10:23:27 UTC (rev 123) +++ trunk/ManagedWinapi/Windows/SystemWindow.cs 2014-11-26 10:31:31 UTC (rev 124) @@ -756,7 +756,8 @@ RECT r = new RECT(); GetWindowRect(_hwnd, out r); - // GetWindowRect returns wrong values for maximized windows when using Windows Aero desktop. + // GetWindowRect returns wrong values for maximized windows when using Windows Aero Glass desktop. + // see http://social.msdn.microsoft.com/Forums/en-US/windowsuidevelopment/thread/6c1c67a9-5548-4e9b-989f-c7dbac0b1375/ // Reduce bounds by negative padding of "glass" pixels for maximized windows. if ((Style & WindowStyleFlags.MAXIMIZE) > 0) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <zi...@us...> - 2014-11-27 09:40:01
|
Revision: 126 http://sourceforge.net/p/mwinapi/code/126 Author: ziewer Date: 2014-11-27 09:39:52 +0000 (Thu, 27 Nov 2014) Log Message: ----------- fixed SystemWindow.Rectangle for maximized windows with Windows Aero Glass to support multi screen setups Modified Paths: -------------- trunk/ManagedWinapi/Windows/SystemWindow.cs Modified: trunk/ManagedWinapi/Windows/SystemWindow.cs =================================================================== --- trunk/ManagedWinapi/Windows/SystemWindow.cs 2014-11-26 12:04:08 UTC (rev 125) +++ trunk/ManagedWinapi/Windows/SystemWindow.cs 2014-11-27 09:39:52 UTC (rev 126) @@ -756,23 +756,20 @@ RECT r = new RECT(); GetWindowRect(_hwnd, out r); - // GetWindowRect returns wrong values for maximized windows when using Windows Aero Glass desktop. - // see http://social.msdn.microsoft.com/Forums/en-US/windowsuidevelopment/thread/6c1c67a9-5548-4e9b-989f-c7dbac0b1375/ - // Reduce bounds by negative padding of "glass" pixels for maximized windows. - if ((Style & WindowStyleFlags.MAXIMIZE) > 0) + try { - // 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) + // GetWindowRect returns wrong values for maximized windows when using Windows Aero Glass desktop + // because there is negative padding of "glass" pixels for maximized windows. + // see http://social.msdn.microsoft.com/Forums/en-US/windowsuidevelopment/thread/6c1c67a9-5548-4e9b-989f-c7dbac0b1375/ + // Limit miximized window size to working area of the corresponding desktop (supporting multi screen setups) + if ((Style & WindowStyleFlags.MAXIMIZE) > 0) { - // remove glass pixels from rectangle - r.Left -= glass; - r.Top -= glass; - r.Right += glass; - r.Bottom += glass; + foreach (var screen in Screen.AllScreens) + if (((Rectangle)r).Contains(screen.WorkingArea)) + return screen.WorkingArea; } } + catch { } // special handling should not cause failure return r; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <zi...@us...> - 2015-07-07 15:14:55
|
Revision: 130 http://sourceforge.net/p/mwinapi/code/130 Author: ziewer Date: 2015-07-07 15:14:52 +0000 (Tue, 07 Jul 2015) Log Message: ----------- improved SystemWindow.TopMost setter: do not activate window when (un)setting topMost state Modified Paths: -------------- trunk/ManagedWinapi/Windows/SystemWindow.cs Modified: trunk/ManagedWinapi/Windows/SystemWindow.cs =================================================================== --- trunk/ManagedWinapi/Windows/SystemWindow.cs 2015-02-04 20:28:10 UTC (rev 129) +++ trunk/ManagedWinapi/Windows/SystemWindow.cs 2015-07-07 15:14:52 UTC (rev 130) @@ -572,11 +572,11 @@ { if (value) { - SetWindowPos(_hwnd, new IntPtr(-1), 0, 0, 0, 0, 3); + SetWindowPos(_hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE); } else { - SetWindowPos(_hwnd, new IntPtr(-2), 0, 0, 0, 0, 3); + SetWindowPos(_hwnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE); } } } @@ -1390,6 +1390,21 @@ private static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int X, int Y, int cx, int cy, uint uFlags); + // special values for hWndInsertAfter + static readonly IntPtr HWND_BOTTOM = new IntPtr(1); + static readonly IntPtr HWND_TOP = new IntPtr(0); + static readonly IntPtr HWND_TOPMOST = new IntPtr(-1); + static readonly IntPtr HWND_NOTOPMOST = new IntPtr(-2); + + // window sizing and positioning flags + const uint SWP_NOSIZE = 0x0001; + const uint SWP_NOMOVE = 0x0002; + const uint SWP_NOACTIVATE = 0x0010; + const uint SWP_DRAWFRAME = 0x0020; + const uint SWP_SHOWWINDOW = 0x0040; + const uint SWP_NOOWNERZORDER = 0x0200; + const uint SWP_ASYNCWINDOWPOS = 0x4000; + [DllImport("user32.dll")] private static extern IntPtr GetWindow(IntPtr hWnd, uint uCmd); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sch...@us...> - 2015-12-11 17:45:27
|
Revision: 136 http://sourceforge.net/p/mwinapi/code/136 Author: schierlm Date: 2015-12-11 17:45:25 +0000 (Fri, 11 Dec 2015) Log Message: ----------- added ToString() to SystemWindow -> now the debugger shows the HWND in watch-window % pushed from GitHub % Author: fk <enoon1 at arcor.de> % Date: Fri Dec 11 14:57:00 2015 +0100 Modified Paths: -------------- trunk/ManagedWinapi/Windows/SystemWindow.cs Modified: trunk/ManagedWinapi/Windows/SystemWindow.cs =================================================================== --- trunk/ManagedWinapi/Windows/SystemWindow.cs 2015-12-11 17:45:18 UTC (rev 135) +++ trunk/ManagedWinapi/Windows/SystemWindow.cs 2015-12-11 17:45:25 UTC (rev 136) @@ -347,7 +347,7 @@ public static SystemWindow[] FilterToplevelWindows(Predicate<SystemWindow> predicate) { List<SystemWindow> wnds = new List<SystemWindow>(); - EnumWindows(new EnumWindowsProc(delegate(IntPtr hwnd, IntPtr lParam) + EnumWindows(new EnumWindowsProc(delegate (IntPtr hwnd, IntPtr lParam) { SystemWindow tmp = new SystemWindow(hwnd); if (predicate(tmp)) @@ -470,7 +470,7 @@ public SystemWindow[] FilterDescendantWindows(bool directOnly, Predicate<SystemWindow> predicate) { List<SystemWindow> wnds = new List<SystemWindow>(); - EnumChildWindows(_hwnd, delegate(IntPtr hwnd, IntPtr lParam) + EnumChildWindows(_hwnd, delegate (IntPtr hwnd, IntPtr lParam) { SystemWindow tmp = new SystemWindow(hwnd); bool add = true; @@ -491,6 +491,17 @@ public IntPtr HWnd { get { return _hwnd; } } /// <summary> + /// Returns a <see cref="System.String" /> that represents this instance. + /// </summary> + /// <returns> + /// A <see cref="System.String" /> that represents this instance. + /// </returns> + public override string ToString() + { + return "HWND 0x" + _hwnd.ToString("X"); + } + + /// <summary> /// The title of this window (by the <c>GetWindowText</c> API function). /// </summary> public string Title This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <zi...@us...> - 2017-12-12 11:41:42
|
Revision: 144 http://sourceforge.net/p/mwinapi/code/144 Author: ziewer Date: 2017-12-12 11:41:40 +0000 (Tue, 12 Dec 2017) Log Message: ----------- Error handling: Catch exception inside ClassName Modified Paths: -------------- trunk/ManagedWinapi/Windows/SystemWindow.cs Modified: trunk/ManagedWinapi/Windows/SystemWindow.cs =================================================================== --- trunk/ManagedWinapi/Windows/SystemWindow.cs 2017-12-12 11:38:03 UTC (rev 143) +++ trunk/ManagedWinapi/Windows/SystemWindow.cs 2017-12-12 11:41:40 UTC (rev 144) @@ -543,17 +543,21 @@ { get { - int length = 64; - while (true) + try { - StringBuilder sb = new StringBuilder(length); - ApiHelper.FailIfZero(GetClassName(_hwnd, sb, sb.Capacity)); - if (sb.Length != length - 1) + int length = 64; + while (true) { - return sb.ToString(); + StringBuilder sb = new StringBuilder(length); + ApiHelper.FailIfZero(GetClassName(_hwnd, sb, sb.Capacity)); + if (sb.Length != length - 1) + { + return sb.ToString(); + } + length *= 2; } - length *= 2; } + catch { return null; } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |