2

What code would effectively take a screenshot of a Form and put a copy of this image on to the clipboard?

So I would like something like: Form.CopyScreenshotToClipboard

CJ7
  • 22,579
  • 65
  • 193
  • 321
  • 1
    [My answer to another question](http://stackoverflow.com/a/10123008/588306) gives code to get a screenshot of a window. – Deanna May 11 '12 at 08:43
  • @Deann +1 to Deanna. Use frm.hWnd to determine the hWnd of a form, which is all you need to use Deanna's answer – MarkJ May 11 '12 at 10:00

2 Answers2

1
  1. Create a hidden PictureBox at design time
  2. Use Deanna's answer to get the form drawn into a PictureBox. Use form.hWnd to get the hWnd
  3. Then copy the picturebox contents onto the clipboard like this
Community
  • 1
  • 1
MarkJ
  • 30,070
  • 5
  • 68
  • 111
0

Just a thought, what about simulating ALT+PRNSCN when your form is the focused form?

This will make a screenshot of the form and put it in the clipboard.

TCS
  • 5,790
  • 5
  • 54
  • 86