Hi again, well, I resolved the problem
the code is here
[VB]
Private Declare Function BitBlt Lib "gdi32" (ByVal hObject As IntPtr, ByVal nXDest As Integer, ByVal nYDest As Integer, ByVal nWidth As Integer, ByVal nHeight As Integer, ByVal hObjectSource As IntPtr, ByVal nXSrc As Integer, ByVal nYSrc As Integer, ByVal dwRop As Integer) As Boolean
Private Declare Function CreateCompatibleBitmap Lib "gdi32" (ByVal hDC As IntPtr, ByVal nWidth As Integer, ByVal nHeight As Integer) As IntPtr
Private Declare Function CreateCompatibleDC Lib "gdi32" (ByVal hDC As IntPtr) As IntPtr
Private Declare Function DeleteDC Lib "gdi32" (ByVal hDC As IntPtr) As Boolean
Private Declare Function DeleteObject Lib "gdi32" (ByVal hObject As IntPtr) As Boolean
Private Declare Function SelectObject Lib "gdi32" (ByVal hDC As IntPtr, ByVal hObject As IntPtr) As IntPtr
Private Declare Function GetDesktopWindow Lib "user32" () As IntPtr
Private Declare Function GetWindowDC Lib "user32" (ByVal hWnd As IntPtr) As IntPtr
Private Declare Function ReleaseDC Lib "user32" (ByVal hWnd As IntPtr, ByVal hDC As IntPtr) As IntPtr
Private Declare Function GetWindowRect Lib "user32" (ByVal hWnd As IntPtr, ByRef rect As RECT) As IntPtr
Private Const SRCCOPY As Integer = &HCC0020
Public Structure RECT
Public left As Integer
Public top As Integer
Public right As Integer
Public bottom As Integer
End Structure RECT
Public Function CaptureWindow(ByVal handle As IntPtr) As Image
get te hDC of the target window
Dim hdcSrc As IntPtr = GetWindowDC(handle)
get the size
Dim windowRect As New RECT
GetWindowRect(handle, windowRect)
Dim width As Integer = windowRect.right - windowRect.left
Dim height As Integer = windowRect.bottom - windowRect.top
create a device context we can copy to
Dim hdcDest As IntPtr = CreateCompatibleDC(hdcSrc)
create a bitmap we can copy it to,
using GetDeviceCaps to get the width/height
Dim hBitmap As IntPtr = CreateCompatibleBitmap(hdcSrc, width, height)
select the bitmap object
Dim hOld As IntPtr = SelectObject(hdcDest, hBitmap)
bitblt over
BitBlt(hdcDest, 0, 0, width, height, hdcSrc, 0, 0, SRCCOPY)
restore selection
SelectObject(hdcDest, hOld)
clean up
DeleteDC(hdcDest)
ReleaseDC(handle, hdcSrc)
get a .NET image object for it
Dim img As Image = Image.FromHbitmap(hBitmap)
free up the Bitmap object
DeleteObject(hBitmap)
Return img
End Function CaptureWindow
[/VB]
Thanks Again