Save image of webbrowser control?

D

dgk

How can I capture an image of a websession? Something like this where
wb1 is a webbrowser?

Dim g As Graphics = wb1.CreateGraphics()
Dim img As Bitmap = g.CopyFromScreen(New Point(0, 0), New Point(0,
0), )
g.Dispose()

I have no idea what to put in for the next argument in the CopyFrom
Screen (the size) nor whether this is the way to go about it. I guess
img = wb1.GetMeTheImage would be too easy.
 
D

dgk

Hi,

Take a look at the drawtobitmap method of the webbrowser control

http://msdn2.microsoft.com/en-us/library/system.windows.forms.control.drawtobitmap.aspx

Ken
--------------------

Closer. But both bitmap and rectangle apparently need to be
instantiated before the call. When I do that, I get a TargetBounds
exception.

Public Class Form1
Private MyImage As Bitmap = New Bitmap(150, 150)
Private MyRectangle As New Rectangle
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
wb1.Navigate("www.google.com")
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

wb1.DrawToBitmap(MyImage, MyRectangle)
End Sub
End Class

Any idea how the rectangle should be created?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top