private static bool EnumWindowsCallback(IntPtr hWnd, IntPtr lParam) { bool specialCapturing = false; if (hWnd == IntPtr.Zero) { return(false); } if (!WindowSnap.IsWindowVisible(hWnd)) { return(true); } if (!WindowSnap.countMinimizedWindows) { if (WindowSnap.IsIconic(hWnd)) { return(true); } } else if (WindowSnap.IsIconic(hWnd) && WindowSnap.useSpecialCapturing) { specialCapturing = true; } if (WindowSnap.GetWindowText(hWnd) == "Program Manager") { return(true); } WindowSnap.windowSnaps.Add(new WindowSnap(hWnd, specialCapturing)); return(true); }
private static Bitmap GetWindowImage(IntPtr hWnd, System.Drawing.Size size) { Bitmap bitmap; try { if (size.IsEmpty || size.Height < 0 || size.Width < 0) { bitmap = null; } else { Bitmap bitmap1 = new Bitmap(size.Width, size.Height); Graphics graphic = Graphics.FromImage(bitmap1); WindowSnap.PrintWindow(hWnd, graphic.GetHdc(), 0); graphic.ReleaseHdc(); graphic.Dispose(); bitmap = bitmap1; } } catch { bitmap = null; } return(bitmap); }
private static Bitmap GetWindowImage(IntPtr hWnd, Size size) { Bitmap result; try { if (size.IsEmpty || size.Height < 0 || size.Width < 0) { result = null; } else { Bitmap bitmap = new Bitmap(size.Width, size.Height); Graphics graphics = Graphics.FromImage(bitmap); IntPtr hdc = graphics.GetHdc(); WindowSnap.PrintWindow(hWnd, hdc, 0u); graphics.ReleaseHdc(); graphics.Dispose(); result = bitmap; } } catch { result = null; } return(result); }
private static string GetWindowText(IntPtr hWnd) { int num = WindowSnap.GetWindowTextLength(hWnd) + 1; StringBuilder stringBuilder = new StringBuilder(num); WindowSnap.GetWindowText(hWnd, stringBuilder, num); return(stringBuilder.ToString()); }
public static WindowSnap GetWindowSnap(IntPtr hWnd, bool useSpecialCapturing) { if (!useSpecialCapturing) { return(new WindowSnap(hWnd, false)); } return(new WindowSnap(hWnd, WindowSnap.NeedSpecialCapturing(hWnd))); }
private static bool NeedSpecialCapturing(IntPtr hWnd) { if (WindowSnap.IsIconic(hWnd)) { return(true); } return(false); }
public static WindowSnapCollection GetAllWindows(bool minimized, bool specialCapturring) { WindowSnap.windowSnaps = new WindowSnapCollection(); WindowSnap.countMinimizedWindows = minimized; WindowSnap.useSpecialCapturing = specialCapturring; WindowSnap.EnumWindowsCallbackHandler lpEnumFunc = new WindowSnap.EnumWindowsCallbackHandler(WindowSnap.EnumWindowsCallback); WindowSnap.EnumWindows(lpEnumFunc, IntPtr.Zero); return(new WindowSnapCollection(WindowSnap.windowSnaps.ToArray(), true)); }
private static void ExitSpecialCapturing(IntPtr hWnd) { WindowSnap.ShowWindow(hWnd, WindowSnap.ShowWindowEnum.Minimize); WindowSnap.SetWindowLong(hWnd, -20, WindowSnap.winLong); if (WindowSnap.minAnimateChanged) { XPAppearance.MinAnimate = true; WindowSnap.minAnimateChanged = false; } }
private WindowSnap(IntPtr hWnd, bool specialCapturing) { this.isIconic = WindowSnap.IsIconic(hWnd); this.hWnd = hWnd; if (specialCapturing) { WindowSnap.EnterSpecialCapturing(hWnd); } WindowSnap.WINDOWINFO wINDOWINFO = new WindowSnap.WINDOWINFO() { cbSize = WindowSnap.WINDOWINFO.GetSize() }; WindowSnap.GetWindowInfo(hWnd, ref wINDOWINFO); bool flag = false; IntPtr parent = WindowSnap.GetParent(hWnd); Rectangle windowPlacement = new Rectangle(); Rectangle rectangle = new Rectangle(); if (WindowSnap.forceMDI && parent != IntPtr.Zero && (wINDOWINFO.dwExStyle & WindowSnap.ExtendedWindowStyles.WS_EX_MDICHILD) == WindowSnap.ExtendedWindowStyles.WS_EX_MDICHILD) { StringBuilder stringBuilder = new StringBuilder(); WindowSnap.GetClassName(parent, stringBuilder, "RunDLL".Length + 1); if (stringBuilder.ToString() != "RunDLL") { flag = true; windowPlacement = WindowSnap.GetWindowPlacement(hWnd); WindowSnap.MoveWindow(hWnd, 2147483647, 2147483647, windowPlacement.Width, windowPlacement.Height, true); WindowSnap.SetParent(hWnd, IntPtr.Zero); rectangle = WindowSnap.GetWindowPlacement(parent); } } Rectangle windowPlacement1 = WindowSnap.GetWindowPlacement(hWnd); this.size = windowPlacement1.Size; this.location = windowPlacement1.Location; this.text = WindowSnap.GetWindowText(hWnd); this.image = WindowSnap.GetWindowImage(hWnd, this.size); if (flag) { WindowSnap.SetParent(hWnd, parent); int left = wINDOWINFO.rcWindow.Left - rectangle.X; int top = wINDOWINFO.rcWindow.Top - rectangle.Y; if ((wINDOWINFO.dwStyle & WindowSnap.WindowStyles.WS_THICKFRAME) == WindowSnap.WindowStyles.WS_THICKFRAME) { left -= 100; //SystemInformation.Border3DSize.Width; top -= 100; //SystemInformation.Border3DSize.Height; } WindowSnap.MoveWindow(hWnd, left, top, windowPlacement.Width, windowPlacement.Height, true); } if (specialCapturing) { WindowSnap.ExitSpecialCapturing(hWnd); } }
private static void EnterSpecialCapturing(IntPtr hWnd) { if (XPAppearance.MinAnimate) { XPAppearance.MinAnimate = false; WindowSnap.minAnimateChanged = true; } WindowSnap.winLong = WindowSnap.GetWindowLong(hWnd, -20); WindowSnap.SetWindowLong(hWnd, -20, WindowSnap.winLong | 524288); WindowSnap.SetLayeredWindowAttributes(hWnd, 0, 1, 2); WindowSnap.ShowWindow(hWnd, WindowSnap.ShowWindowEnum.Restore); WindowSnap.SendMessage(hWnd, 15, 0, 0); }
private static bool NeedSpecialCapturing(IntPtr hWnd) { return(WindowSnap.IsIconic(hWnd)); }
private static Rectangle GetWindowPlacement(IntPtr hWnd) { WindowSnap.RECT rect = default(WindowSnap.RECT); WindowSnap.GetWindowRect(hWnd, ref rect); return(rect); }
public static WindowSnapCollection GetAllWindows() { return(WindowSnap.GetAllWindows(false, false)); }
private static Rectangle GetWindowPlacement(IntPtr hWnd) { WindowSnap.RECT rECT = new WindowSnap.RECT(); WindowSnap.GetWindowRect(hWnd, ref rECT); return(rECT); }