Private Function GetWindowPicture(ByVal hWnd As Integer) As _
Bitmap
Dim g As Graphics
Dim hdcDest As IntPtr
Dim hdcSrc As Integer
Dim bm As Bitmap
Dim r As New RECT()
Dim w, h As Integer
GetWindowRect(hWnd, r)
w = r.Right - r.Left
h = r.Bottom - r.Top
bm = New Bitmap(w, h)
g = g.FromImage(bm)
hdcSrc = GetWindowDC(hWnd)
hdcDest = g.GetHdc
BitBlt(hdcDest.ToInt32, 0, 0, w, h, hdcSrc, 0, 0, _
SRCCOPY)
g.ReleaseHdc(hdcDest)
ReleaseDC(hWnd, hdcSrc)
Return bm
End Function
|