private static void HighlightingCurrentWindow(IntPtr hWnd) { SSWindowsFunctions.RECT rc = new SSWindowsFunctions.RECT(); SSWindowsFunctions.GetWindowRect(hWnd, out rc); _highlightWindow.Left = rc.Left; _highlightWindow.Top = rc.Top; _highlightWindow.Width = rc.Right - rc.Left; _highlightWindow.Height = rc.Bottom - rc.Top; Debug.WriteLine($"Selected rec = {rc}"); Debug.WriteLine($"Left:{_highlightWindow.Left} Top:{_highlightWindow.Top} Width:{_highlightWindow.Width} Height:{_highlightWindow.Height}"); _highlightWindow.Show(); }
public Bitmap GetScreenshtOfSelectedWindow(IntPtr handle) { Contract.Requires(handle != IntPtr.Zero); SSWindowsFunctions.RefreshWindow(handle); SSWindowsFunctions.RECT rc = new SSWindowsFunctions.RECT(); SSWindowsFunctions.GetWindowRect(handle, out rc); var bound = new Rectangle(rc.Left, rc.Top, rc.Right - rc.Left, rc.Bottom - rc.Top); var result = new Bitmap(bound.Width, bound.Height); using (var graphics = Graphics.FromImage(result)) { graphics.CopyFromScreen(new Point(bound.Left, bound.Top), Point.Empty, bound.Size); } return(result); }