Jump to content
Xtreme .Net Talk

woklet

Avatar/Signature
  • Posts

    29
  • Joined

  • Last visited

Everything posted by woklet

  1. Thanks much, Tygur I downloaded that program and it works really quite well. I'm set for now. In my spare time I can try to translate the C++ code into VB.NET code. (If it's possible...) Thanks again
  2. Now, as far as rendering the HTML page to a bitmap, I�ve come this far (doing my best to interpret Rob Manderson�s C++ article into VB.NET). I don�t get an error when I render my HTML page to the device context; at least that�s what I think I�m doing. I only now need to get my device context rendering into a bitmap, but I�m stuck. Do I need to use the BitBlt function? Private Sub Button12_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button12.Click Dim doc As mshtml.HTMLDocument = DirectCast(Me.AxWebBrowser1.Document, mshtml.HTMLDocument) Dim bodyElement As mshtml.IHTMLElement Dim render As mshtml.IHTMLElementRender Dim render2 As IHTMLElementRender Dim dd As mshtml.HTMLBody bodyElement = doc.body render2 = bodyElement Dim BitMap As New Bitmap(600, 400) Dim g As Graphics = Graphics.FromImage(BitMap) Dim memDC As IntPtr memDC = g.GetHdc() render2.DrawToDC(memDC) Try BitMap.FromHbitmap(memDC) Catch exc As Exception MsgBox(Err.Description) MsgBox(exc.ToString) End Try BitMap.Save("c:\newread\test.tif", System.Drawing.Imaging.ImageFormat.Tiff) MsgBox("Image created!") End Sub The following code is after your imports but before your Public Class Form1 <ComVisible(True), ComImport(), _ Guid("3050f669-98b5-11cf-bb82-00aa00bdce0b"), _ InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)> _ Interface IHTMLElementRender Sub DrawToDC(<[in]()> ByVal hDC As IntPtr) Sub SetDocumentPrinter(<[in](), MarshalAs(UnmanagedType.BStr)> ByVal _ bstrPrinterName As String, <[in]()> ByVal hDC As IntPtr) End Interface 'IHTMLElementRender It must be needed so DrawToDc accepts a normal pointer rather than a remotable handle Any help would be appreciated! Thank in advance Ben
  3. The following code will produce a �form� screen shot Private Sub btnSave_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles btnSave.Click ' Save the picture. Dim bm As Bitmap = GetFormImage() bm.Save("c:\newread\test.tif", System.Drawing.Imaging.ImageFormat.Tiff) 'Beep() End Sub Private Function GetFormImage() As Bitmap Dim me_gr As Graphics = Me.CreateGraphics Dim bm As New Bitmap(Me.ClientSize.Width, _ Me.ClientSize.Height, me_gr) Dim bm_gr As Graphics = me_gr.FromImage(bm) Dim bm_hdc As IntPtr = bm_gr.GetHdc Dim me_hdc As IntPtr = me_gr.GetHdc BitBlt(bm_hdc, 0, 0, Me.ClientSize.Width, _ Me.ClientSize.Height, _ me_hdc, 0, 0, SRCCOPY) me_gr.ReleaseHdc(me_hdc) bm_gr.ReleaseHdc(bm_hdc) Return bm End Function You�ll need to declare the BitBlt function and the variable SRCCOPY after your Public Class Form1 Private Declare Auto Function BitBlt Lib "gdi32.dll" (ByVal _ hdcDest As IntPtr, ByVal nXDest As Integer, ByVal _ nYDest As Integer, ByVal nWidth As Integer, ByVal _ nHeight As Integer, ByVal hdcSrc As IntPtr, ByVal nXSrc _ As Integer, ByVal nYSrc As Integer, ByVal dwRop As _ System.Int32) As Boolean Private Const SRCCOPY As Integer = &HCC0020
  4. I'm looking for source code on how to convert an entire HTML page into a BITMAP image. Not a screenshot; I'm able to get that. But my BITMAP needs to save what is not currently displayed as well(scroll). Any help would be greatly appreciated! Thanks in advance Ben
×
×
  • Create New...