feup
asked on
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.
How can I (for example), pass the text to a memo component, in order to read it?
thanks.
ASKER
If you tell me how to get the HTML code of the page, I'll give you the points.
Thanks
Thanks
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.b ody.innerT ext));
{can be either innerhtml /outerhtml / innertext / outertext}
end;
MSHTML_TLB; {imported with dhtmledit control}
procedure TForm1.Button1Click(Sender
var
Doc : IHtmlDocument2 ;
begin
Doc := Webbrowser1.Document as IHtmlDocument2;
Memo1.Clear;
Memo1.lines.add(trim(doc.b
{can be either innerhtml /outerhtml / innertext / outertext}
end;
ASKER
great!
Make an answer, and the points are yours.
Thanks
Joao
Make an answer, and the points are yours.
Thanks
Joao
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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.
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.
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',f alse);
showmessage('page saved as c:\a.html');
end;
hope this solves some troubles,
now im going for some christmas drinks :-))
Regards Barry
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',f
showmessage('page saved as c:\a.html');
end;
hope this solves some troubles,
now im going for some christmas drinks :-))
Regards Barry
ASKER
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 :))
Thanks again
Merry Christmas, and don't drink too much :))
procedure TForm1.Button1Click(Sender
begin
opendialog1.execute;
webbrowser1.oleobject.navi
end;
procedure TForm1.Button2Click(Sender
var
vInput,vOutput,cInput,Cout
begin
WebBrowser1.ExecWB(OLECMDI
WebBrowser1.ExecWB(OLECMDI
Webbrowser1.refresh;
memo1.SetFocus;
memo1.pastefromclipboard;
end;
Regards Barry