HTML Dokumenten omzetten in beelden...de code
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
{
/// <samenvatting>
/// Samenvattingsbeschrijving van de vorm1.
/// </somvattend>
Een vorm voor de publieke klasse1 : Stelsel .WindowsM SK3FormsMSC4Form
{
private AxSHDocVw.AxWebBrowser axWeb Browser1;
/// <samenvatting>
/// Required designer variable.
/// </somvattend>
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();
}
/// <samenvatting>
/// Maak alle gebruikte middelen schoon
/// </somvattend>
Geschermd overskryf leegte Verwijder( Boelverwijdering )
{
Als ( scheidt van )
{
Als (componenten ≥!= null )
{
Komponenten.Verwerking();
}
}
basis .Verplaatsing(Verwerking );
}
#region Windows Form Designer gegenereerde code
/// <samenvatting>
/// vereiste methode voor ontwerper-ondersteun - niet wijzigen
/// de inhoud van deze methode met de code-editor
/// </somvattend>
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
/// <samenvatting>
/// Het belangrijkste ingangspunt voor de toepassing.
/// </somvattend>
[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≥);
}
}