I have 2 forms:1 is parent form and another is child form. When I click capture the active screen, the title(Black area) of the image that I captured will be in black color. I couldn't capture the whole active screen(child form) including the form title.
Here is my code:
private void btnCapture_Click(object sender, EventArgs e)
{
Form activeChild = this.ActiveMdiChild;
if (activeChild == null){MessageBox.Show("no active form child found!");return;}else{SaveAsBitmap(activeChild, activeChild + ".Jpeg");MessageBox.Show("Screen Captured successfully.");}}public void SaveAsBitmap(Control control, string fileName){SaveFileDialog dialog = new SaveFileDialog(); dialog.Filter = "JPeg Image|*.jpg|Bitmap Image|*.bmp|Gif Image|*.gif";if (dialog.ShowDialog() == DialogResult.OK){Graphics g = control.CreateGraphics();Bitmap bmp = new Bitmap(control.Width, control.Height); control.DrawToBitmap(bmp, new Rectangle(0, 0, control.Width, control.Height)); bmp.Save(dialog.FileName, ImageFormat.Jpeg);//bmp.Save("C://test.jpg", ImageFormat.Jpeg);}}