🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.cppbuilder.internet.web
1 messages
1 total messages Started by virender Wed, 30 Aug 2006 10:16
How to capture Offscreen browser using TCppWebBrowser
#690
Author: virender
Date: Wed, 30 Aug 2006 10:16
56 lines
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");
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads