# HTML Dokumenten omzetten in beelden...de code

<datetime class="hidden">2004-06-30T00:00</datetime>

<!-- category -- mostlylucidcouk, Imported -->
Welnu, na een beetje spelen Ik' heb iets dat nu werkt , IM SK3 ik heb geen Win, maar dit lijkt te werken.

Met behulp van System;

Met behulp van System.Drawing;

Met behulp van het systeem.Drawing.ImagingM SK2

Met behulp van het systeem.Collecties;

Met behulp van System.ComponentModel;

Met behulp van het systeem.WindowsM SK1Forms;

Met behulp van System.Data;

Met mshtml;

Met behulp van het systeem.RuntimeM SK1InteropServices;

Met behulp van Microsoft.Win32;

Namespace ThumbMaker

{

/// &lt;samenvatting&gt;

/// Samenvattingsbeschrijving van de vorm1.

/// &lt;/somvattend&gt;

Een vorm voor de publieke klasse1 : Stelsel .WindowsM SK3FormsMSC4Form

{

private AxSHDocVw.AxWebBrowser axWeb Browser1;

/// &lt;samenvatting&gt;

/// Required designer variable.

/// &lt;/somvattend&gt;

Private System.Komponentmodel.Container components M SK2 null ;

private const string urlStr = "http://newsM SK3bbcMSC4coMST5ukM ST6 |

Publiek formulier1()

{

//

// Required for Windows Form Designer support

//

Initialiseer Komponent();

Voorwerp o = null ;

Dit .Visible= vals ;

axWebBrowser1.Navigate(urlStrMST2 ref oMst3 ref OM st4 ref óMSt5 refoMstr6

}

const int WM\_PAINT

const int WM\_PRINTCLIENT

const int WM\_ERASEBKGND

const int WM\_PRINT

Const int PRF\_CHILDREN  = 0x00000010;

Const int PRF\_kliënt  = 0x00000004;

publieke leegte GrabWindow()

{

IntPtr hWnd = dit .Handle;

IntPtr hBmp;

Bitmap MyBitmap= null ;

IntPtr hDCMem = GDI32.Gekompatibel DCcreëerM SK2IntPTRMSC3 null );

IntPtr hDC = Gebruiker32.GetWindowDCMSC2hWndM SK3

hBmp = GDIM SK1Gekompatibel Bitmap maken(hDCMSC3IntPtrMska4axWebBrowserM Ska5Width ,(InntPtr≥Mska7ax WebBrowzerMske8HeightMsek9

Gebruiker32.ReleaseDC(hWndM SK2 hDC );

IntPtr hOld = GDI 32.SelectObjectM SK2hDCMem, hBmpMSC4

Gebruiker32.SendMessage(hWndM SK2 WM\_PRINT , hDCMem, nieuwe IntPtrM SK3PRF\_kliënt  | PRF\_CHILDREN));

GDI32.SelectObject (hDCMemM SK2 hOld);

GDI32.DeleteObject(hDCMemM SK2

MyBitmap = BitmapM SK1VanHbitmap (hBmp);

MyBitmap.Save( "test.png" ,ImageFormat.Png);

Dit .Close();

}

/// &lt;samenvatting&gt;

/// Maak alle gebruikte middelen schoon

/// &lt;/somvattend&gt;

Geschermd overskryf leegte Verwijder( Boelverwijdering )

{

Als ( scheidt van )

{

Als (componenten ≥!= null )

{

Komponenten.Verwerking();

}

}

basis .Verplaatsing(Verwerking  );

}

#region Windows Form Designer gegenereerde code

/// &lt;samenvatting&gt;

/// vereiste methode voor ontwerper-ondersteun - niet wijzigen

/// de inhoud van deze methode met de code-editor

/// &lt;/somvattend&gt;

Private void InitializeComponent()

{

System.Ressourcen.Resource-Manager-resourcen M SK2 nieuw System .Re Resourcen.Resurse-ManageerMSC5 type ( FormaatMske7

Deze .axWebBrowser1 = nieuwe AxSHDocVwM SK3AxWebBbrowserSSK4

((Sisteem.Komponentmodel .IsupportInitialiseerM SK3 dit msc4axWebBrowserMsc5BeginInitMSC6

Dit .SuspendLayout();

//

// axWebBrowser1

//

Dit .axWebBrowser1.Dock =SystemM SK3WindowsMST4FormsMSC5DockingStyleMSP6FillMSV7

Dit .axWebBrowser1.Geaktiveerd = waar ;

Dit .axWebBrowserM SK1Location = nieuw System.DrawingMSC4PointMST5 0);

Dit .axWebBrowser1.OcxState = ((SystemM SK4Windows+.Forma's~.AxHost+.StateMSC8resourcen~.GetObject+M SK10 \"\axWeb Browser\1.\Oc xState="\ \ )));\

Dit .axWebBrowser1.Size = nieuw systeemM SK3Drawing

Dit .axWebBrowser1.TabIndex = 0;

Dit .axWebBrowserM SK1DocumentCompleet += nieuwe AxSHDocVw.DWebBbrowserEventsMSC4\_DocumentCompleteEventHandlerM SK1 dit .axWebBrowser1\_DocumentComplete);

//

// Formaat1

//

Dit .AutoScale = vals ;

Dit .AutoScaleBaseSize = nieuw System.DrawingM SK3SizeMSC4 13);

Dit .Clientgrootte = nieuw systeem.DrawingM SK3 grootteMSC4 768);

Dit .Controls.AddM SK2 Dit ♫.axWebBrowser ♫

Dit .FormBorderStyle =System.WindowsM SK3FormsMSC4Form BorderStyleMST5NietMst6

Deze .naam = "vorm1" |

Dit .ShowInTaskbar = vals ;

Deze .Teks = "Formaat1"

((Sisteem.Komponentmodel .IsupportInitialiseer

Dit .ResumeLayout( vals );

}

#endregion

/// &lt;samenvatting&gt;

/// Het belangrijkste ingangspunt voor de toepassing.

/// &lt;/somvattend&gt;

[STAThread]

Statische leegte Main()

{

Aansoek.Run( nieuw formulierM SK2

}

private void axWebBrowser1\_DocumentComplete( voorwerpverstuurer , AxSHDocVwM SK3DWebBrowserEventsMSC4\_DocumentCompleteEvent e)

{

GrabWindow();

}

}

Klas GDI32

{

[DllImport( "GDI32.dllM SK3 |

Publiek statische externe bool BitBlt(IntPtr hdcDest,InstPtr nXDest ,InntPtrnYDestSk3

Intptr nWidth,IntPtr nHeight,InntPtr hdcSrcM SK2

Intptr nXSrc,IntPtr nYSrc ,InntPtr dwRop);

[DllImport( "GDI32.dllM SK3 |

public static extern IntPtr CreateCompatibleBitmap(IntPTR hdc,InstPtr nWidthM SK2

IntPtr n Hoogte);

[DllImport( "GDI32.dllM SK3 |

public static extern IntPtr CreateCompatibleDC(IntPTR hdc);

[DllImport( "GDI32.dllM SK3 |

Publiek statische externe bool DeleteDC(IntPtr hdc);

[DllImport( "GDI32.dllM SK3 |

public statisch extern bool DeleteObject(IntPtr hObject≥);

[DllImport( "GDI32.dllM SK3 |

Publiek statische externe IntPtr GetDeviceCaps(IntPTR hdc,InstPtr nIndexM SK2

[DllImport( "GDI32.dllM SK3 |

Publiek statische externe IntPtr SelectObject(IntPTR hdc,InstPtr hgdiobjM SK2

}

Klas Gebruiker32

{

[DllImport( M SK1Gebruiker 32.dll" |

Publiek statische externe IntPtr GetDesktopWindow();

[DllImport( M SK1Gebruiker 32.dll" |

Publiek statische externe IntPtr GetWindowDC(IntPtri hWnd);

[DllImport( M SK1Gebruiker 32.dll" |

Publiek statische externe IntPtr ReleaseDC(IntPTR hWnd,InstPtr hDC );

[DllImport( M SK1Gebruiker 32.dll" |

public statisch extern int SendMessage(IntPtr hWnd, int MsgM SK2 IntPTR wParamMSC3 InтPtr lParam≥);

}

}