read the webbrowser component window!

Imagine I browse a page with a text content.

How can I (for example), pass the text to a memo component, in order to read it?

thanks.
feupAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

intheCommented:
there are 2 ways ,either by saving the webbrowser text to file then loading it into the memo using loadfromfile() or the easier way is to do this:

procedure TForm1.Button1Click(Sender: TObject);
begin
opendialog1.execute;
webbrowser1.oleobject.navigate(opendialog1.filename);
end;

procedure TForm1.Button2Click(Sender: TObject);
var
 vInput,vOutput,cInput,Coutput : OleVariant;
begin
 WebBrowser1.ExecWB(OLECMDID_SELECTALL,0,vInput,vOutput);
 WebBrowser1.ExecWB(OLECMDID_COPY,0,cInput,cOutput);
 Webbrowser1.refresh;
 memo1.SetFocus;
 memo1.pastefromclipboard;
 end;

Regards Barry
0
feupAuthor Commented:
If you tell me how to get the HTML code of the page, I'll give you the points.


Thanks
0
intheCommented:
add to uses
  MSHTML_TLB; {imported with dhtmledit control}


procedure TForm1.Button1Click(Sender: TObject);
var
Doc :  IHtmlDocument2 ;
begin
Doc := Webbrowser1.Document as IHtmlDocument2;
Memo1.Clear;
Memo1.lines.add(trim(doc.body.innerText));
{can be either innerhtml /outerhtml / innertext / outertext}
end;

0
Cloud Class® Course: MCSA MCSE Windows Server 2012

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

feupAuthor Commented:
great!

Make an answer, and the points are yours.


Thanks

Joao
0
intheCommented:
cheers
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
feupAuthor Commented:
Hi inthe.

Could you please help on a doubt?

- Whi do I get an error on the line of the copy, saying that my webbrowser component is not registered as a drop target?

What is the component DHTML?

How do I copy the text to a file?

thanks, and sorry for asking this after I have given you the points.

0
intheCommented:
1:
about the first error either something is wrong in the code you are calling or it is using a different declaration of some function you are using.are you putting MSHTML_TLB and ActiveX in the uses clause?
also add to the bottom of your unit:


initialization
  OleInitialize(nil);

finalization
  OleUninitialize;

end.

2:
in delphi on the component menu click "import activeX" and in the box that pops up select  "DHTMLEdit control for ie5" (or is it "microsoft html object library"?)(well try them both) and click install ,this will then install the components on the activeX tab of your components tab and create some units(one of them will create MSHTML_TLB.pas in your delphi\imports directory).
have a look at the other activeX's as well ,as there are many more that you can import to get components on the activex tab...

3:
to save to file:

uses activeX;

procedure TForm1.Save1Click(Sender: TObject);
var
persist :ipersistfile;
begin
persist := (webbrowser1.document as ipersistfile);
persist.save('c:\a.html',false);
showmessage('page saved as c:\a.html');
end;

hope this solves some troubles,
now im going for some christmas drinks :-))
Regards Barry
0
feupAuthor Commented:
I could now solve my problem, because someone had the same prblem, and with the redirection of the messages (as you answerd it) solved it.


Thanks again

Merry Christmas, and don't drink too much :))
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.