Link to home
Start Free TrialLog in
Avatar of PeterdeB
PeterdeBFlag for Netherlands

asked on

How to copy the URL in the IE Address bar into an Tedit on my form?

Hi guys!

The title is quite selfexplanatory I guess. Just want to copy the URL in the IE Address bar into a TEdit on my form preferrably by a button click. Further more I want to grab text from a webpage which I normally can only view by right clicking > view source. How can I grab that text and put it into a TMemo on my form?

Two questions therefore I double the reward for working samples on both!

Regards from Holland,

Let me know if any info is missing ok?

PeterdeB
ASKER CERTIFIED SOLUTION
Avatar of ginsonic
ginsonic
Flag of Romania image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Exactly an answer for you ( BTW work perfect ):

uses
  shdocvw_tlb;

procedure TForm1.Button1Click(Sender: TObject);
var
  Sw: IShellWindows;
begin
  sw := CoShellWindows.Create;
  Edit1.Text:=(Sw.Item(0) as IWebbrowser2).LocationUrl;  // replace 0 with your IE instance order number ..1..2..3..4..etc
end;
...get the HTML Code out of all Internet Explorer Instances?

http://www.swissdelphicenter.ch/en/printcode.php?id=1615
Attention! you get the document source ( the HTML ) and not displayed text. Your Memo can't read the code as a browser. If you wish to diplay as IE then use a TWebBrowser or better EnbeddedWB from my first link.
Avatar of PeterdeB

ASKER

Splendid ginsonic!!!

Regards from Holland,

PeterdeB
Glad to can help :)

Regards from Romania,
Nick aka ginsonic