471,319 Members | 1,942 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,319 software developers and data experts.

Screen capture with IE AxWebBrowser control and hidden Window

Hi,

I'm trying to capture hidden window's data that is in IE's
AxSHDocVw.AxWebBrowser ActiveX control.

If Control and window are visible, code below works but if Control
and it's window is hidden e.g. emmedded in dll, code does not save
data as an picture. How should I handle this kind of situation?

How can I get data printed to file if AxWebBrowser is hidden and
in dll file?

Cheers,

public void CaptureWindow(AxSHDocVw.AxWebBrowser axWebBrowser1,
string fileName,
ImageFormat imageFormat)
{
// Handle to BrowserControl
IntPtr hwnd = axWebBrowser1.Handle;

// Get handle to Browser's ActiveX Window
int hdcSrc = User32.GetWindowDC(hwnd.ToInt32()),
hdcDest = GDI32.CreateCompatibleDC(hdcSrc), // Creating memory device
context
hBitmap = GDI32.CreateCompatibleBitmap(hdcSrc, // Creating Bitmpat in
memory
axWebBrowser1.Width, axWebBrowser1.Height); // Width and Heigth of the
Browser's Window
// For creating color bitmap
GDI32.SelectObject(hdcDest,hBitmap);
// Performs a bit-block transfer of the color data corresponding to a
rectangle of
// pixels from the specified source device context into a destination
device context
GDI32.BitBlt(hdcDest, 0, 0,
GDI32.GetDeviceCaps(hdcSrc,8), // Width of destination rectangle
GDI32.GetDeviceCaps(hdcSrc,10), // Heigth of destination rectangle
hdcSrc,0,0,0x00CC0020);

// Saving Bitmap as file. Format can be e.g. gif, jpeg, tiff etc.
SaveImage(hBitmap, fileName, imageFormat);
// Releasing resources
User32.ReleaseDC(hwnd.ToInt32(), hdcSrc);
GDI32.DeleteDC(hdcDest);
GDI32.DeleteObject(hBitmap);
}

Dec 14 '05 #1
0 3457

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Me Mine | last post: by
5 posts views Thread by Sambucus | last post: by
3 posts views Thread by Chris | last post: by
3 posts views Thread by Clint MacDonald | last post: by
18 posts views Thread by DavidS | last post: by
2 posts views Thread by Rune Strand | last post: by
reply views Thread by rosydwin | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.