Capture the form on the screen during runtime

Are you interested in video capturing then you can use this article which is about Capture the form on the screen during runtime

With .NET 2.0, screen capturing becomes much more flexible and easier. The following code sample will capture the runtime forms image on to bitmap file. Put this code in the click event of the form so that you can capture the form in any state.

System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(this.Width, this.Height);
this.DrawToBitmap(bmp, this.ClientRectangle);


Author: mahendar reddy04 Aug 2011 Member Level: Bronze   Points : 0

send in a detailed example

Author: Phagu Mahato25 Feb 2014 Member Level: Gold   Points : 4

You can try this code

internal void CaptureScreen()
Graphics g1 = CreateGraphics();
Image MyImage = new Bitmap(ClientRectangle.Width,
ClientRectangle.Height, g1);
Graphics g2 = Graphics.FromImage(MyImage);
IntPtr dc1 = g1.GetHdc();
IntPtr dc2 = g2.GetHdc();
BitBlt(dc2, 0, 0, ClientRectangle.Width,
ClientRectangle.Height, dc1, 0, 0, 13369376);
MyImage.Save(@"Captured.jpg", ImageFormat.Jpeg);
[System.Runtime.InteropServices.DllImportAttribute( "gdi32.dll")]
private static extern bool BitBlt(
IntPtr hdcDest,
int nXDest
int nYDest
int nWidth
int nHeight
IntPtr hdcSrc
int nXSrc
int nYSrc
Int32 dwRop

  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name: