How to capture screenshot without Bitblt

KKQQ

Newcomer
Joined
Jun 8, 2005
Messages
2
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!~
 
Code:
      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
 
Last edited:
rustyd said:
Code:
      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 ?
 
rustyd said:
Code:
      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.
 
If KKQQ is still following this:

KKQQ: Did you ever find a replacement for SendKeys in the Compact Framework? I just ran into the same troubles over here. Hopefully, you found an answer to this within the last 3 years. :)
 
Back
Top