Originally posted by NickFitz
View Post
I have fixed it. And am posting the code back here like a good little boy.
Code:
public Bitmap CaptureScreenToPictureBox(int hDcPbx)
{
int hdcSrc = User32.GetWindowDC(User32.GetDesktopWindow()),
hdcDest = GDI32.CreateCompatibleDC(hdcSrc),
hBitmap = GDI32.CreateCompatibleBitmap(hdcSrc,200, 200);
GDI32.SelectObject(hdcDest, hBitmap);
GDI32.StretchBlt(hdcDest, 0, 0,200,200, hdcSrc, 0, 0,1200,800, 0x00CC0020);
Bitmap screenShot = Image.FromHbitmap((IntPtr)hBitmap);
return screenShot;
}
Then the call is changed thusly
Code:
Example f = new Example(); this.pictureBox1.Image = f.CaptureScreenToPictureBox(this.pictureBox1.CreateGraphics().GetHdc().ToInt32());



Comment