Screenshot of webbrowser control...(ie screenshot of web page in web browser control)

  • 13 years ago

    I needed Vb.NET code for capturing a screenshot of a webbrowser control........         the webbrowser may not be the first in zorder.. ie not on top.....

    i tried both PrintWindow and WM_PRINT.. but both dowsn't work for me.. i get a black screenshot with PrintWindow (even if the webbrowser is on top of other controls and focussed...)....


    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            Dim webWidth As Integer = WebBrowser1.Width
            Dim webHeight As Integer = WebBrowser1.Height
            Dim result As Boolean
            Dim webHwnd As Long
            webHwnd = WebBrowser1.Handle
            Dim bitDest As New Bitmap(webWidth, webHeight)
            Dim g As Graphics
            g = Graphics.FromImage(bitDest)
            Dim hdc As Long
            hdc = g.GetHdc()
            result = PrintWindow(webHwnd, hdc, 0)
            If result Then
                PictureBox1.Image = bitDest
                bitDest.Save("c:\\bit.jpg", System.Drawing.Imaging.ImageFormat.Jpeg)
            End If
    end sub


  • 13 years ago

    Hey , The best way for u is pls download the follow link

  • 13 years ago

    hey thnx man.. it's exactly what i need... gr8 code... 

Post a reply

Enter your message below

Sign in or Join us (it's free).


Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“The question of whether computers can think is just like the question of whether submarines can swim.” - Edsger W. Dijkstra