Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Re: how can i get the HDC of this web browser conrol

7 views
Skip to first unread message

Igor Tandetnik

unread,
Jan 19, 2007, 4:04:49 PM1/19/07
to
Jakein2006 <pen...@163.com> wrote:
> I have a web browser control in a formview like this:
> CWebBrowser2* m_pWebCtrl;
>
> I wonder how can i get the HDC of this web browser conrol so I can
> use the following statement to copy the image inside web browser
> into my memory DC?
>
> BitBlt(hMemDC, 0, 0, nWidth, nHeight,hSrcDC, 0, 0, SRCCOPY);
>
> i want hSrcDC point to web browser window.

WebBrowser's window does not contain anything interesting. You want the
document window which is an (indirect) child of WebBrowser's window. Get
the document pointer with IWebBrowser2::get_Document (probably also
available as CWebBrowser2::GetDocument or something like that), query
for IOleWindow, call GetWindow to obtain the HWND. Once you have that,
call GetDC API to get HDC corresponding to this HWND. Don't forget to
call ReleaseDC when you are done with it.

Alternatively, you can use IHTMLElementRender interface. Every element,
including document and <img>, is supposed to implement it. Disclaimer: I
haven't tried it myself.
--
With best wishes,
Igor Tandetnik

With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925


0 new messages