Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Snapshot of Internet Explorer
Message
General information
Forum:
ASP.NET
Category:
Other
Miscellaneous
Thread ID:
00951151
Message ID:
00951388
Views:
6
'This function captures a screenshot of a window.
You have to pass the handle to the internet explorer page.


Private Declare Function GetWindowDC Lib "user32" (ByVal hwnd As Integer) As Integer
Private Declare Function GetDC Lib "user32" (ByVal hwnd As Integer) As Integer
Private Declare Function BitBlt Lib "gdi32" (ByVal hDestDC As Integer, ByVal x As Integer, ByVal y As Integer, ByVal nWidth As Integer, ByVal nHeight As Integer, ByVal hSrcDC As Integer, ByVal xSrc As Integer, ByVal ySrc As Integer, ByVal dwRop As Integer) As Integer
Private Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Integer, ByRef lpRect As RECT) As Integer
Private Const SRCCOPY = &HCC0020

Private Structure RECT
Dim Left As Integer
Dim Top As Integer
Dim Right As Integer
Dim Bottom As Integer
End Structure



Private Function ScreenCapture(ByVal hWnd As Integer) As Image
'Create a bitmap big enough to hold picture
Dim Rec As RECT
GetWindowRect(hWnd, Rec)
Dim myImage As Image = New Bitmap(Rec.Right - Rec.Left, Rec.Bottom - Rec.Top)
'Get the graphics object for the bitmap
Dim gr1 As Graphics = Graphics.FromImage(myImage)
'Get the device Context from the graphics object
Dim dc1 As IntPtr = gr1.GetHdc()
'Get the DC of the window you want to capture
Dim dc2 As Integer = GetWindowDC(hWnd) '***Use GetDC if you only want Client Portion of window...

'Copy the Other windows DC into the one we created
BitBlt(dc1.ToInt64, 0, 0, Rec.Right - Rec.Left, Rec.Bottom - Rec.Top, dc2, 0, 0, SRCCOPY)
'cleanup
gr1.ReleaseHdc(dc1)
'Save the bitmap...
Return myImage
End Function
Previous
Reply
Map
View

Click here to load this message in the networking platform