Solved

get IE link

Posted on 2001-08-01
7
212 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:
mnasman 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
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 

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:mnasman
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:mnasman
ID: 6350975
That's great, you are welcome any time :o)
Mohammed
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
This video discusses moving either the default database or any database to a new volume.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

747 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now