
Originally Posted by
.paul.
just press your prtscr button. (read the full thread)
for choices about what to capture, doubleclick the icon in the system tray.
if you just want to incorporate a screen capture into your app, the capturing is done in the clsScreenCapture.vb class
Ok im using this
vb.net Code:
Private Sub Button4_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
Dim image As Bitmap
Dim fileName As String = ""
fileName = My.Application.Info.DirectoryPath & "\images\" & Replace(Now.ToString.Replace("/", "-"), ":", ".") & ".png"
image = CaptureWindow(User32.GetForegroundWindow, Nothing)
image.Save(fileName, Imaging.ImageFormat.Png)
End Sub
Public Function CaptureWindow(ByVal handle As IntPtr, ByVal r As Rectangle) As Image
' get the size
Dim windowRect As New User32.RECT
Dim width As Integer
Dim height As Integer
If r = Nothing Then
User32.GetWindowRect(handle, windowRect)
'windowRect.left = SplitContainer2.Panel1.Left
'windowRect.top = SplitContainer2.Panel1.Left
width = windowRect.right - windowRect.left
height = windowRect.bottom - windowRect.top
End If
Dim img As Bitmap = New Bitmap(width, height)
Dim gr As Graphics = Graphics.FromImage(img)
gr.CopyFromScreen(windowRect.left, windowRect.top, 0, 0, New Size(width, height))
Return img
End Function
Public Class User32
Public Structure RECT
Public left As Integer
Public top As Integer
Public right As Integer
Public bottom As Integer
End Structure 'RECT
Declare Function GetDesktopWindow Lib "user32.dll" () As IntPtr
Declare Function GetWindowRect Lib "user32.dll" ( _
ByVal hwnd As IntPtr, _
ByRef lpRect As RECT) As Int32
Declare Function GetForegroundWindow Lib "user32.dll" _
Alias "GetForegroundWindow" () As IntPtr
End Class 'User32
End Class
but the problem is that it will take a screenshot of the current active window. How can I change that to take a screen shot of the application and not the curent active window?
Thank you