public Rectangle PhotoCanvasRect() { bool found = false; IntPtr inner = IntPtr.Zero; WinApiInterop.NativeMethods.TraverseWindowTree(base.hWnd, PhotoViewerWindow.PhotoCanvasClassName, ref found, ref inner); if (found) { // Canvas var windowRectangle = new WinApiInterop.RECT(); WinApiInterop.NativeMethods.GetWindowRect(inner, ref windowRectangle); var image = WinApiInterop.NativeMethods.GetWindowImage(inner, 0, 0, (windowRectangle.Right - windowRectangle.Left), (windowRectangle.Bottom - windowRectangle.Top)); var flatImage = new FlatImage(image); var borders = PhotoViewerWindow.ImageBorders(flatImage); return(new Rectangle { X = windowRectangle.Left + borders.Left, Y = windowRectangle.Top + borders.Top, Width = borders.Width, Height = borders.Height, }); } else { return(Rectangle.Empty); } }
public Bitmap GetShot() { var rect = new WinApiInterop.RECT(); var b = WinApiInterop.NativeMethods.GetWindowRect(this.hWnd, ref rect); return(WinApiInterop.NativeMethods.GetWindowImage(this.hWnd, 0, 0, (rect.Right - rect.Left) + 1, (rect.Bottom - rect.Top) + 1)); // TODO: +1 ? }