mirror of
https://github.com/kangyu-california/PersistentWindows.git
synced 2025-05-11 21:15:38 +02:00
#224, avoid restore window with non-positive client rect
This commit is contained in:
parent
a10e344604
commit
c9d1eff0ad
2 changed files with 11 additions and 5 deletions
|
@ -2079,17 +2079,20 @@ namespace PersistentWindows.Common
|
|||
if (!User32.IsWindowVisible(hwnd))
|
||||
continue;
|
||||
*/
|
||||
var rect = new RECT();
|
||||
User32.GetWindowRect(hwnd, ref rect);
|
||||
if (rect.Width <= 1 && rect.Height <= 1)
|
||||
continue;
|
||||
|
||||
if (string.IsNullOrEmpty(GetWindowClassName(hwnd)))
|
||||
continue;
|
||||
|
||||
if (string.IsNullOrEmpty(GetWindowTitle(hwnd)))
|
||||
continue;
|
||||
|
||||
var rect = new RECT();
|
||||
User32.GetWindowRect(hwnd, ref rect);
|
||||
if (rect.Width <= 1 && rect.Height <= 1)
|
||||
continue;
|
||||
User32.GetClientRect(hwnd, out rect);
|
||||
if (rect.Width <= 0 || rect.Height <= 0)
|
||||
continue;
|
||||
|
||||
// workaround runtime overflow exception in release build
|
||||
//SystemWindow window = new SystemWindow(hwnd);
|
||||
//WindowStyleFlags style = window.Style;
|
||||
|
|
|
@ -212,6 +212,9 @@ namespace PersistentWindows.Common.WinApiBridge
|
|||
[return: MarshalAs(UnmanagedType.Bool)]
|
||||
public static extern bool GetWindowRect(IntPtr hWnd, ref RECT lpRect);
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
public static extern bool GetClientRect(IntPtr hWnd, out RECT lpRect);
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
[return: MarshalAs(UnmanagedType.Bool)]
|
||||
public static extern bool IntersectRect([Out] out RECT lprcDst, [In] ref RECT lprcSrc1, [In] ref RECT lprcSrc2);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue