Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I have created a blank form with something drawn using drawing class. I have tried to use Bitblt to copy the screenshot of the form to a bitmap variable. However, the .net compact framework seems not supporting Bitblt in the same way.

 

I need an alternative to capture the screenshot without Bitblt!~

Posted (edited)
      
     SendKeys.SendWait("%{PRTSC}")
     Dim iData As IDataObject = Clipboard.GetDataObject()
     If iData.GetDataPresent(DataFormats.Bitmap) Then
       Dim bmp As Bitmap = iData.GetData(DataFormats.Bitmap)
' TODO: Replace newfilename with the new filename to save screen shot as
       bmp.Save(<newfilename>, Imaging.ImageFormat.Bmp)
       bmp.Dispose()
     End If

Edited by rustyd
rustyd
Posted
      
     SendKeys.SendWait("%{PRTSC}")
     Dim iData As IDataObject = Clipboard.GetDataObject()
     If iData.GetDataPresent(DataFormats.Bitmap) Then
       Dim bmp As Bitmap = iData.GetData(DataFormats.Bitmap)
' TODO: Replace newfilename with the new filename to save screen shot as
       bmp.Save(<newfilename>, Imaging.ImageFormat.Bmp)
       bmp.Dispose()
     End If

 

Thanks very much for the codes

I'm using this on compact framework that runs on pocket pc and some classes / methods above are not supported by c.f. directly (e.g. sendkeys, .Save, etc.). Would that possible to covert the code above to a c.f. compatible version ?

  • Leaders
Posted
      
     SendKeys.SendWait("%{PRTSC}")
     Dim iData As IDataObject = Clipboard.GetDataObject()
     If iData.GetDataPresent(DataFormats.Bitmap) Then
       Dim bmp As Bitmap = iData.GetData(DataFormats.Bitmap)
' TODO: Replace newfilename with the new filename to save screen shot as
       bmp.Save(<newfilename>, Imaging.ImageFormat.Bmp)
       bmp.Dispose()
     End If

 

Just a warning about this code: the unsespecting user will lose the data he has stored on the clipboard. Possible solution: grab what is on the clipboard and restore it after your screen capture operation.

[sIGPIC]e[/sIGPIC]
  • 2 years later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...