PRINTSCREEN VIA CÓDIGO
Olá pessoal !
Existe alguma forma de dar um printscreen via código ?
Um abraço a todos.
Existe alguma forma de dar um printscreen via código ?
Um abraço a todos.
Ve se te ajuda
Private Declare Function GetDesktopWindow Lib [Ô]user32[Ô] () As Long
Private Declare Function GetDC Lib [Ô]user32[Ô] (ByVal hWnd As Long) As Long
Private Declare Function BitBlt Lib [Ô]gdi32[Ô] (ByVal hDC 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 opCode As Long) As Long
Private Declare Function ReleaseDC Lib [Ô]user32[Ô] (ByVal hWnd As Long, ByVal hDC As Long) As Long
Private Sub Form_Load()
Me.WindowState = vbMinimized
Dim scrHwnd As Long
scrHwnd = GetDesktopWindow
Dim shDC As Long
shDC = GetDC(scrHwnd)
Dim screenWidth As Long, screenHeight As Long
screenWidth = Screen.Width \ Screen.TwipsPerPixelX
screenHeight = Screen.Height \ Screen.TwipsPerPixelY
BitBlt FormScreenCapture.hDC, 0, 0, screenWidth, screenHeight, shDC, 0, 0, vbSrcCopy
ReleaseDC scrHwnd, shDC
FormScreenCapture.Picture = FormScreenCapture.Image
Me.WindowState = vbNormal
End Sub
Peguei esse código e colei em um form, ao rodar, da erro nessa linha abaixo, precisa referenciar algo no vb ?, ou esta incompleto, seria apenas um exemplo ?
BitBlt FormScreenCapture.hDC, 0, 0, screenWidth, screenHeight, shDC, 0, 0, vbSrcCopy
BitBlt FormScreenCapture.hDC, 0, 0, screenWidth, screenHeight, shDC, 0, 0, vbSrcCopy
Tópico encerrado , respostas não são mais permitidas