САБЖ
| Код | class ScreenMaker { [DllImport("user32.dll")] static extern int ReleaseDC(IntPtr hWnd, IntPtr hDC);
[DllImport("user32.dll")] static extern IntPtr GetDC(IntPtr hWnd);
[DllImport("gdi32.dll")] static extern bool BitBlt(IntPtr hdc, int nXDest, int nYDest, int nWidth, int nHeight, IntPtr hdcSrc, int nXSrc, int nYSrc, uint dwRop);
const uint SRCCOPY = 0x00CC0020;
static IntPtr NIL = new IntPtr();
static public Bitmap CaptureScreenRect(Rectangle rect) { Bitmap bit = new Bitmap(rect.Width, rect.Height); IntPtr ScreenDC = GetDC(NIL); try { //////// Тут BitBlt возвращает false /////// BitBlt(bit.GetHbitmap(), 0, 0, rect.Width, rect.Height, ScreenDC, rect.Left, rect.Top, SRCCOPY); } finally { ReleaseDC(NIL, ScreenDC); } return bit; } }
|
|