[COLOR=Gray]/// <summary>
///[/COLOR] [COLOR=Green]the class that performs the snapshot of your html page.[/COLOR]
[COLOR=Gray]/// </summary>[/COLOR]
[COLOR=Blue]public class[/COLOR] _win32
{
[COLOR=Blue]#region[/COLOR] " Api Calls "
[COLOR=Blue]private const int[/COLOR] SRCCOPY = 0xCC0020;
[DllImport("gdi32.dll")]
[COLOR=Blue]private static extern[/COLOR] IntPtr BitBlt (IntPtr hDestDC, int x, int y, int nWidth, int nHeight, IntPtr hSrcDC, int xSrc, int ySrc, int dwRop);
[DllImport("gdi32.dll")]
[COLOR=Blue]private static extern[/COLOR] IntPtr CreateCompatibleBitmap (IntPtr hdc, int nWidth, int nHeight);
[DllImport("gdi32.dll")]
[COLOR=Blue]private static extern[/COLOR] IntPtr CreateCompatibleDC (IntPtr hdc);
[DllImport("gdi32.dll")]
[COLOR=Blue]private static extern[/COLOR] IntPtr DeleteDC (IntPtr hdc);
[DllImport("gdi32.dll")]
[COLOR=Blue]private static extern[/COLOR] IntPtr DeleteObject (IntPtr hObject);
[DllImport("user32.dll")]
[COLOR=Blue]private static extern[/COLOR] IntPtr GetDC (IntPtr hwnd);
[DllImport("user32.dll")]
[COLOR=Blue]private static extern int[/COLOR] GetWindowRect (IntPtr hwnd, ref Rectangle lpRect);
[DllImport("user32.dll")]
[COLOR=Blue]private static extern[/COLOR] IntPtr ReleaseDC (IntPtr hwnd, IntPtr hdc);
[DllImport("gdi32.dll")]
[COLOR=Blue]private static extern[/COLOR] IntPtr SelectObject (IntPtr hdc, IntPtr hObject);
[DllImport("user32.dll", EntryPoint="FindWindowA")]
[COLOR=Blue]private static extern[/COLOR] IntPtr FindWindow (string lpClassName, string lpWindowName);
[DllImport("user32.dll", EntryPoint="FindWindowExA")]
[COLOR=Blue]private static extern[/COLOR] IntPtr FindWindowEx (IntPtr hWnd1,IntPtr hWnd2, string lpsz1, string lpsz2);
[COLOR=Blue]#endregion[/COLOR]
[COLOR=Blue]public[/COLOR] Rectangle clientRect=new Rectangle();
[COLOR=Blue]public[/COLOR] Bitmap bmp;
[COLOR=Blue]public[/COLOR] _win32()
{
IntPtr val = this.WebHandle();
if(val!=IntPtr.Zero)
{
this.dcHandle( val );
}
}
[COLOR=Blue]public[/COLOR] IntPtr WebHandle()
{
IntPtr hwnd = FindWindow( "IEFRAME" , null );
IntPtr hwndSrc = IntPtr.Zero;
if(hwnd != IntPtr.Zero)
{
hwndSrc = FindWindowEx( hwnd , IntPtr.Zero , "Shell DocObject View" , null );
hwndSrc = FindWindowEx( hwndSrc , IntPtr.Zero , "InterNet Explorer_Server" , null );
GetWindowRect( hwndSrc , ref clientRect );
}
return hwndSrc;
}
[COLOR=Blue]public void[/COLOR] dcHandle(IntPtr hHandle)
{
IntPtr srcHdc = gDc( hHandle );
IntPtr destHdc = CreateCompatibleDC( srcHdc );
IntPtr bmpDc = CreateCompatibleBitmap( srcHdc , clientRect.Width , clientRect.Height - 145 );
CreateImageCanvas( destHdc , srcHdc , bmpDc , clientRect , SRCCOPY );
bmp = bMap( bmpDc ); /// create the bitmap to save.
CleanDcs( hHandle , destHdc , srcHdc , bmpDc );
return;
}
[COLOR=Blue]public[/COLOR] IntPtr gDc(IntPtr hHandle)
{
return GetDC( hHandle );
}
[COLOR=Blue]public void[/COLOR] CreateImageCanvas(IntPtr dest , IntPtr source , IntPtr bDc , Rectangle rct , int dwRop )
{
IntPtr objDc = SelectObject( dest , bDc );
BitBlt( dest , 0 , 0 , clientRect.Width , clientRect.Height - 145 , source, 0 , 0 , SRCCOPY );
SelectObject( dest , objDc );
return;
}
[COLOR=Blue]public[/COLOR] Bitmap bMap(IntPtr b)
{
return Bitmap.FromHbitmap(b);
}
[COLOR=Blue]public void[/COLOR] CleanDcs(IntPtr hHandle , IntPtr dest , IntPtr source , IntPtr bDc )
{
ReleaseDC( hHandle , source );
DeleteDC( dest );
DeleteObject( bDc );
return;
}
}