PrintWindow() private method

private PrintWindow ( IntPtr hwnd, IntPtr hDC, uint nFlags ) : bool
hwnd System.IntPtr
hDC System.IntPtr
nFlags uint
return bool
Ejemplo n.º 1
0
        public static Bitmap getBitmap(IntPtr handle)
        {
            Bitmap bmp = null;

            try {
                Wim32API.Rect rect = new Wim32API.Rect();
                Wim32API.GetWindowRect(handle, ref rect);
                bmp = new Bitmap(rect.Right - rect.Left, rect.Bottom - rect.Top);
                Graphics memoryGraphics = Graphics.FromImage(bmp);
                IntPtr   dc             = memoryGraphics.GetHdc();
                bool     success        = Wim32API.PrintWindow(handle, dc, 0);
                memoryGraphics.ReleaseHdc(dc);
            }
            catch (Exception e) { bmp = null; }
            return(bmp);
        }