Advertisement
4_2005-2006 Graphics #167849

Screenshot Without Using Clipboard Or DIB

Seen many posts using api for printscreen keypress, but what about the info on clipboard? Seen others that copy clipboard to temp var, and set back after, but why waste resources and processing when you can do it the right way? Also seen classes using DIB, wayyy slow. This = best way! =D This uses two tricks that arent very known, so here you go! When using GetDC(0) as our source, we actually capture the screen, and when using picture.image=picture.picture.

AI

Riepilogo AI: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.

Codice sorgente
original-source
Private Declare Function BitBlt Lib "gdi32" (ByVal hDestDC As Long, ByVal X As Long, ByVal Y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal dwRop As Long) As Long
Private Declare Function GetDC Lib "USER32" (ByVal hwnd As Long) As Long
Private Sub ScreenShot()
  'Important Precursors
  'All these can be set in form load
  'The Picturebox can also be Visible=False
  'and this will still work
  Picture1.Width = Screen.Width
  Picture1.Height = Screen.Height
  Picture1.AutoRedraw = True
  BitBlt Picture1.hDC, 0, 0, Screen.Width / Screen.TwipsPerPixelX, Screen.Height / Screen.TwipsPerPixelY, GetDC(0), 0, 0, vbSrcCopy
  Picture1.Picture = Picture1.Image
  SavePicture Picture1.Picture, App.Path & "/screen.bmp"
End Sub
Commenti originali (3)
Recuperato da Wayback Machine