Solved

get IE link

Posted on 2001-08-01
7
221 Views
Last Modified: 2010-04-06
I want a text box in my application to be able to receive IE links and display it's text and url.
is there any way to do this?

thanks
0
Comment
Question by:pin_plunder
7 Comments
 
LVL 15

Expert Comment

by:simonet
ID: 6343367
What do you mean by IE links? URLs?

Alex
0
 
LVL 22

Accepted Solution

by:
Mohammed Nasman earned 200 total points
ID: 6343747
Hello

simonet, where have you been, I didn't see your comments form long time.

pin_plunder, This code will give you all the links in the address bar from ie in memo box, even if you have more than one ie window open

//===========
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    Memo1: TMemo;
    procedure Button1Click(Sender: TObject);
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

//Copy the text from the IE Address Bar Edit box.
function GetIEEditText(wnd: THandle; Param: Integer): Bool; stdcall;
var
  wndClass: array[0..127] of char;
begin
  //Get the object class name.
  GetClassName(wnd, wndClass, SizeOf(wndClass));
  //Is the desired object?
  if wndClass = 'Edit' then
  begin
    SendMessage(wnd, EM_SETSEL, 0, -1); //Select the whole text.
    SendMessage(wnd, WM_COPY, 0, 0);    //Copy it to the ClipBoard.
    SendMessage(Param, WM_PASTE, 0, 0); //Paste from the ClipBoard to the Memo1.
    SendMessage(Param, WM_CHAR, 13, 0); //Send ENTER to the Memo1.
    Result := False;                    //Stop searching.
  end else
    Result := True;                     //Continue searching.
end;

//Searches the ComboBox where the edit box is on.
function GetIEAddres(wnd: THandle; Param: Integer): Bool; stdcall;
var
  wndClass: array[0..127] of char;
begin
  //Get the object class name.
  GetClassName(wnd, wndClass, SizeOf(wndClass));
  //Is the desired object?
  if wndClass = 'ComboBoxEx32' then
  begin
    EnumChildWindows(wnd, @GetIEEditText, Param); //Enum the child objects.
    Result := False;                              //Stop searching.
  end else
    Result := True;                               //Continue searching.
end;

//Searchs the Internet Explorer.
function FindIExplorer(wnd: THandle; Param: Integer): Bool; stdcall;
var
  wndClass: array[0..127] of char;
begin
  //Get the object class name.
  GetClassName(wnd, wndClass, SizeOf(wndClass));
  //Is the Internet Explorer main form?
  if wndClass = 'IEFrame' then
    EnumChildWindows(wnd, @GetIEAddres, Param); //Enum the child objects.
  Result := True; //Continue searching other IExplorer windows.                      
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  //Enum all the Windows's windows. The LParam is the memo's handle.
  EnumWindows(@FindIExplorer, Memo1.Handle);
end;

end.

Best regards
Mohammed Nasman
0
 

Expert Comment

by:BryGuy
ID: 6345330
You can also use DDE:

var
  IeClient : TDdeClientConv;
  p : PChar;
begin
  IeClient := TDdeClientConv.Create (nil);
  try
    with IeClient do
    begin
      SetLink ('IEXPLORE', 'WWW_GetWindowInfo');
      p := RequestData ('0xFFFFFFFF');
      // p is your URL, etc.... do whatever you want with it...
      StrDispose (p);
      CloseLink;
    end;
  finally
    IeClient.Free;
  end;
end;
0
Is Your AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

 

Author Comment

by:pin_plunder
ID: 6345779
mnasman your code worked all right, but I've got some simple questions about it:
1) how do you know the Internet Explorer Class is called "IEFrame"
2) how can I do the same with Netscape

the points are already yours but first please explain me these things.

many thanks.
0
 
LVL 22

Expert Comment

by:Mohammed Nasman
ID: 6347712
Hello pin_plunder

  for the first question, if you are run winsight that come with delphi, it will show u all the running processes, and you will find that the IE have the class {IEFrame}, so from there you can know these things.

for second question, Honestly I havn't tried that with netscape, I havn't used it from long time, but if I have a free time, I will install it and try that

Mohammed
0
 

Author Comment

by:pin_plunder
ID: 6350355
thank you. ahh!, thanks to your last comments it was possible to me to do the same with netscape.
THANKS.
0
 
LVL 22

Expert Comment

by:Mohammed Nasman
ID: 6350975
That's great, you are welcome any time :o)
Mohammed
0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Newbie Thread Programming 1 152
Dev Express grid collapse 2 45
Multiple image collision 13 75
Graphics32 under Delphi 10.1 Berlin 2 66
A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

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