views:

40

answers:

2

Hey all, I've been trying to find the code that allowed me to capture an entire web page using the webbrowser1 control and i believe also a picturebox or 2.. but i am not able to find the code that i used a couple months ago! I've been goodgling until I'm all googled out!

If anyone knows of the code for VB6 then please post a link to it!.

Thanks,

David

A: 

Do you mean the HTML source? If so you can add a reference to the Microsoft HTML obj Library and;

Dim doc As MSHTML.HTMLDocument
set doc = YourWebBrowserCtrl.Document
msgbox doc.documentElement.outerHTML

However this will not return the exact source as at this point its been parsed by IE. (It also won't include doc type or anything else preceding the opening <html> tag.

If you do want the source, add an internet transfer control and just call .openURL to get the full content.

Alex K.
A: 
    Dim DrawSize As New Size(1024, 768)
    Using MyBrowser As New WebBrowser
        MyBrowser.ScrollBarsEnabled = False
        MyBrowser.Size = DrawSize
        MyBrowser.Navigate("http://www.stackoverflow.com")
        While MyBrowser.ReadyState <> WebBrowserReadyState.Complete
            Application.DoEvents()
        End While
        Using myBitmap As New Bitmap(DrawSize.Width, DrawSize.Height)
            MyBrowser.DrawToBitmap(myBitmap, New Rectangle(New Point(0, 0), DrawSize))
            myBitmap.Save("C:\test.jpeg")
        End Using
    End Using
volody