PRINTSCREEN VIA CÓDIGO

XAVIER 25/10/2014 10:35:49
#442152
Olá pessoal !

Existe alguma forma de dar um printscreen via código ?

Um abraço a todos.
ANGELO 29/10/2014 14:08:14
#442200
Resposta escolhida
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

LIZA 30/10/2014 08:21:08
#442216
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
Tópico encerrado , respostas não são mais permitidas