?
Solved

How can I programmatically get the displayed text from tcppwebbrowser?

Posted on 2003-03-31
5
Medium Priority
?
287 Views
Last Modified: 2011-10-03
How can I programmatically get the displayed text from tcppwebbrowser?

I'm currently using

  WB1->ExecWB(Shdocvw_tlb::OLECMDID_SELECTALL,0,TNoParam(),TNoParam());
  WB1->ExecWB(Shdocvw_tlb::OLECMDID_COPY,0,TNoParam(),TNoParam());
  WB1->ExecWB(Shdocvw_tlb::OLECMDID_CLEARSELECTION,0,TNoParam(),TNoParam());

  if( Clipboard()->HasFormat(CF_TEXT) )
  {
     *S = Clipboard()->AsText;
     return true;
  }

However, it causes my pc to freak out.  I can't open any new Internet Explorer windows while the program is running after this.
0
Comment
Question by:mattsimmons
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 30

Expert Comment

by:Axter
ID: 8241456
Here's some code I pull out of the newsgroup:

#include <mshtml.h>

IHTMLDocument2 *HTMLDocument = NULL;
IPersistFile *PersistFile = NULL;

if(SUCCEEDED(CppWebBrowser1->Document->QueryInterface(IID_IHTMLDocument2,
(LPVOID*)&HTMLDocument)))
{
    if(SUCCEEDED(HTMLDocument->QueryInterface(IID_IPersistFile, (LPVOID*)&PersistFile)))
    {
        PersistFile->Save(WideString(String("temp.html")), true);
        PersistFile->Release();
    }  HTMLDocument->Release();
}

// Then load the text into a TStringList

TStringList *HTMLSource = new TStringList;
HTMLSource->LoadFromFile("temp.html");
// use HTMLSource then...
delete HTMLSource;


Hope it helps
0
 

Author Comment

by:mattsimmons
ID: 8241605
Actually, that solution only reads the source code from the browser, not the displayed text.  I found a solution to my own problem.  

Thank you though.

My own solution...

IHTMLDocument2 * Doc;
IHTMLElement * Element;
try
{
  if(!WB1->Document || !SUCCEEDED(WB1->Document->QueryInterface(IID_IHTMLDocument2,(LPVOID*)&Doc)))
  {
     return false;
  }

  if (!Doc )
  {
    ShowMessage("Failed to load document interface to IE");
    return false;
  }

  Element = Doc->body;
  Doc->Release();

  IESourceText = Element->get_innerHTML();
  IEDisplayedText = Element->get_innerText()
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 8242947
You can and should close this question to get it out of the Open Queue.  Please see:
   
http://www.apollois.com/EE/Help/Closing_Questions.htm#AnsMyOwnQues
for info and tips.
-- Dan
0
 
LVL 6

Expert Comment

by:Mindphaser
ID: 8245414
mattsimmons asked to have this question closed. If there isn't any objection I will
 
  PAQ & refund

in 72 hours.

** Mindphaser - Community Support Moderator **
0
 

Accepted Solution

by:
SpideyMod earned 0 total points
ID: 8273137
PAQ'd and all 250 points refunded.

SpideyMod
Community Support Moderator @Experts Exchange
0

Featured Post

Enroll in August's Course of the Month

August's CompTIA IT Fundamentals course includes 19 hours of basic computer principle modules and prepares you for the certification exam. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.
Suggested Courses
Course of the Month13 days, 5 hours left to enroll

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question