🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.internet.web
Article #1323

Saving a Web Page from TCcpbrowser without a dialog

#1323
From: murone
Date: Thu, 24 Mar 2005 15:24
60 lines
2641 bytes
I am trying to save a Web page from tccpbrowser. If I use the code below, it 
works fine, but explorer handles it and pops up a dialog box. I also have 
code below that which will display the source, and then can be saved. My 
question is how do I save the complete page to include images, without 
showing a dialog box to the user?

Thanks,

ba

  PROMPTS USER WITH DIALOG BOX:
  AnsiString FileName = ExtractFilePath ( ParamStr (0) )
                       + "ExecWB.OLECMDID_SAVEAS.html";

   char filename [MAXPATH];

   strcpy ( filename, FileName.c_str() );

   TVariant Variant = filename;

   CppWebBrowser1->ExecWB(
        Shdocvw_tlb::OLECMDID_SAVEAS,
        Shdocvw_tlb::OLECMDEXECOPT_DODEFAULT, &Variant  );



DISPLAYS HTML SOURCE:
  AnsiString Source = "";

  IHTMLDocument2 *htm = NULL;     // #include <mshtml.h>


  if(CppWebBrowser1->Document&&SUCCEEDED(CppWebBrowser1->Document->QueryInterface(IID_IHTMLDocument2,(LPVOID*)&htm)))
    {IPersistStreamInit *spPsi = NULL;    // ocidl.h

  if(SUCCEEDED(htm->QueryInterface(IID_IPersistStreamInit,(LPVOID*)&spPsi)) 
&& spPsi)
    {IStream *spStream = NULL;            // objidl.h
     OleCheck(CreateStreamOnHGlobal(NULL, true, &spStream));
     if(spStream)
       {__int64 nSize = 0;
        STATSTG ss;
        LARGE_INTEGER nMove;
        nMove.QuadPart = 0;
        OleCheck(spPsi->Save(spStream, true));
        OleCheck(spStream->Seek(nMove,STREAM_SEEK_SET,(ULARGE_INTEGER 
*)&nSize));
        OleCheck(spStream->Stat(&ss, STATFLAG_NONAME));
        nSize = ss.cbSize.QuadPart;

        Source.SetLength(nSize);
        OleCheck(spStream->Read((void *)Source.data(), 
nSize,(ULONG*)&nSize));
        OleCheck(spStream->Release());
       }

     spPsi->Release();
    }
  htm->Release();
 }
Technical Details
Message-ID: <4242dbbc@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news.glorb.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Thread: feeec,17dd1985d663bc5a,start
X-Google-Attributes: gidfeeec,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: "murone" <banterbubba@yahoo.com>
Newsgroups: borland.public.cppbuilder.internet.web
Subject: Saving a Web Page from TCcpbrowser without a dialog
Date: Thu, 24 Mar 2005 10:24:44 -0500
Lines: 62
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.2180
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180
X-RFC2646: Format=Flowed; Original
NNTP-Posting-Host: 67.165.45.154
Message-ID: <4242dbbc@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1111677884 67.165.45.154 (24 Mar 2005 07:24:44 -0800)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news.glorb.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail