Article View: borland.public.cppbuilder.internet.web
Article #690How to capture Offscreen browser using TCppWebBrowser
From: virender
Date: Wed, 30 Aug 2006 10:16
Date: Wed, 30 Aug 2006 10:16
56 lines
3423 bytes
3423 bytes
Hi,
I am working on BCB6 and using TCppWebBrowser.
I saw a code to save browser as *.jpg or *.bmp but that code is not
able to capture off-screen part is there any way by which we can
capture browser.
Code should capture all the browser till the scrollbar range(both
vertical and horizontal)
Code that i have used is:
TComInterface<IHTMLDocument2> Doc;
if(SUCCEEDED(CppWebBrowser1->Document->QueryInterface(IID_IHTMLDocument2,(LPVOID*)&Doc))
)
{
TComInterface<IHTMLElement> Body;
if(SUCCEEDED(Doc->get_body(&Body)))
{
TComInterface<IHTMLBodyElement> BodyElement;
if(SUCCEEDED(Body->QueryInterface(IID_IHTMLBodyElement,(LPVOID*)&BodyElement)))
{
BodyElement->put_noWrap(VARIANT_TRUE);
// hide scrollbars
//TComInterface<IHTMLStyle> Style;
//if(SUCCEEDED(Body->get_style(&Style)))
//Style->put_borderStyle(WideString("none"));
//BodyElement->put_scroll(WideString("no"));
TComInterface<IHTMLElement2> BodyElement2;
if(SUCCEEDED(Body->QueryInterface(IID_IHTMLElement2,(LPVOID*)&BodyElement2)))
{
long ScrollWidth = 0;
BodyElement2->get_scrollWidth(&ScrollWidth);
long ScrollHeight = 0;
BodyElement2->get_scrollHeight(&ScrollHeight);
CppWebBrowser1->Width = ScrollWidth;
CppWebBrowser1->Height = ScrollHeight;
TComInterface<IViewObject> ViewObject;
CppWebBrowser1->Document->QueryInterface(IID_IViewObject,(LPVOID*)&ViewObject);
if(ViewObject)
{
std::auto_ptr<Graphics::TBitmap> Source(new
Graphics::TBitmap);
Source->Width = CppWebBrowser1->Width;
Source->Height = CppWebBrowser1->Height;
RECT SourceRect = Rect(0, 0,
ScrollWidth,ScrollHeight);
if(SUCCEEDED(ViewObject->Draw(DVASPECT_CONTENT,
1,NULL, NULL, this->Handle, Source->Canvas->Handle,
(_RECTL*)&SourceRect, NULL, NULL,0)))
Source->SaveToFile("c:\\somefile.bmp");
Technical Details
Message-ID:
<1156932977.880610.165590@e3g2000cwe.googlegroups.com>Path:
arc1-ca.pugleaf.net!g2news2.google.com!postnews.google.com!e3g2000cwe.googlegroups.com!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Thread: feeec,e441e086c3f34c7f,start X-Google-Attributes: gidfeeec,public X-Google-Language: ENGLISH,ASCII-7-bit Path: arc1-ca.pugleaf.net!g2news2.google.com!postnews.google.com!e3g2000cwe.googlegroups.com!not-for-mail From: "virender" <viren.mehta.bciit@gmail.com> Newsgroups: borland.public.cppbuilder.internet.web Subject: How to capture Offscreen browser using TCppWebBrowser Date: 30 Aug 2006 03:16:17 -0700 Organization: http://groups.google.com Lines: 57 Message-ID: <1156932977.880610.165590@e3g2000cwe.googlegroups.com> NNTP-Posting-Host: 220.225.70.2 Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" X-Trace: posting.google.com 1156932982 22842 127.0.0.1 (30 Aug 2006 10:16:22 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Wed, 30 Aug 2006 10:16:22 +0000 (UTC) User-Agent: G2/0.2 X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1),gzip(gfe),gzip(gfe) X-HTTP-Via: 1.0 PTPROXY Complaints-To: groups-abuse@google.com Injection-Info: e3g2000cwe.googlegroups.com; posting-host=220.225.70.2; posting-account=D-5Xfg0AAACbNg3QxkhJwumFHtgS3Fqa