Ver Mensaje Individual
  #2 (permalink)  
Antiguo 24/12/2009, 15:54
Avatar de seba123neo
seba123neo
 
Fecha de Ingreso: febrero-2007
Ubicación: Esperanza, Santa Fe
Mensajes: 1.046
Antigüedad: 18 años
Puntos: 19
Respuesta: Convertir un control WebBrowser y su contenido en BMP

Hola, la verdad que feo no poder cambiar de versión y actualizarte a la ultima.pero ningun ejemplo te funciona? por ejemplo vi que el webbrowser tiene un metodo llamado DrawToBitmap pero dicen que esta funcion no esta soportada y que no funciona en algunas paginas dependiendo del javascript.viendo un poco mas me encontre con un ejemplo que funciona muy bien, lo hace con la api BitBtl, lo arme porque no venia con la api.

Código vbnet:
Ver original
  1. Public Class Form1
  2.  
  3.     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
  4.  
  5.     Public Enum TernaryRasterOperations
  6.         SRCCOPY = &HCC0020
  7.         SRCPAINT = &HEE0086
  8.         SRCAND = &H8800C6
  9.         SRCINVERT = &H660046
  10.         SRCERASE = &H440328
  11.         NOTSRCCOPY = &H330008
  12.         NOTSRCERASE = &H1100A6
  13.         MERGECOPY = &HC000CA
  14.         MERGEPAINT = &HBB0226
  15.         PATCOPY = &HF00021
  16.         PATPAINT = &HFB0A09
  17.         PATINVERT = &H5A0049
  18.         DSTINVERT = &H550009
  19.         BLACKNESS = &H42
  20.         WHITENESS = &HFF0062
  21.     End Enum
  22.  
  23.     Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  24.         WebBrowser1.Navigate("http://www.google.com.ar")
  25.     End Sub
  26.  
  27.     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  28.         Dim srcGraphics As Graphics = WebBrowser1.CreateGraphics
  29.         Try
  30.             Dim destGraphics As Graphics = PictureBox1.CreateGraphics
  31.             Try
  32.                 Dim hdcDest As IntPtr = destGraphics.GetHdc
  33.                 Dim hdcSrc As IntPtr = srcGraphics.GetHdc
  34.                 BitBlt(hdcDest, 0, 0, WebBrowser1.ClientRectangle.Width, WebBrowser1.ClientRectangle.Height, hdcSrc, 0, 0, CType(TernaryRasterOperations.SRCCOPY, Integer))
  35.                 srcGraphics.ReleaseHdc(hdcSrc)
  36.                 destGraphics.ReleaseHdc(hdcDest)
  37.             Finally
  38.                 CType(destGraphics, IDisposable).Dispose()
  39.             End Try
  40.         Finally
  41.             CType(srcGraphics, IDisposable).Dispose()
  42.         End Try
  43.     End Sub
  44. End Class

ojala te funcione con el framework 1.1

saludos.
__________________
" Todos Somos Ignorantes; lo que pasa es que no todos ignoramos las mismas cosas " - Albert Einstein