Beispiel #1
0
        public void CaptureActiveControl(IntPtr handle)
        {
            IntPtr activeControl = Win.GetActiveControl(handle);

            if (activeControl != IntPtr.Zero)
            {
                Win.RECT activeWindowRect;
                Win.GetWindowRect(activeControl, out activeWindowRect);
                Rect myRect;
                System.Drawing.Point caretPosition = GetCaretPosition();
                if (caretPosition == System.Drawing.Point.Empty)
                {
                    double width  = activeWindowRect.Right - activeWindowRect.Left;
                    double height = activeWindowRect.Bottom - activeWindowRect.Top;
                    ConversionHelper.ResizeToArea(ref width, ref height, 900);
                    myRect = new Rect(activeWindowRect.Left, activeWindowRect.Top, width, height);
                }
                else
                {
                    if (PointIsOutsideRect(caretPosition, activeWindowRect))
                    {
                        myRect = new Rect(activeWindowRect.Left, activeWindowRect.Top, Math.Max(50, Math.Min(activeWindowRect.Right - activeWindowRect.Left, 200)), Math.Max(25, Math.Min(activeWindowRect.Bottom - activeWindowRect.Top, 100)));
                    }
                    else
                    {
                        myRect = new Rect(caretPosition.X, caretPosition.Y, 1, 1);
                        myRect.Inflate(100, 50);
                    }
                }

                ScreenCapture.SetAreaOfFocus(myRect);
                CaptureScreen();
            }
        }
Beispiel #2
0
 public void CaptureActiveWindow(IntPtr handle)
 {
     Win.RECT rect;
     if (Win.GetWindowRect(handle, out rect))
     {
         ScreenGrabs.Add(ScreenCapture.Grab(rect));
     }
 }