uses ddeman;
.....
procedure TForm1.Button1Click(Sender:TObject);
var
dde:TDdeClientConv;
begin
dde:=TDdeClientConv.Create(self);
if dde.SetLink('Iexplore','WWW_GetWindowInfo') then
Edit1.Text:=dde.RequestData('0xffffffff,sURL,sTitle');
else
ShowMessage('IE is not running!');
end;
{
Copy the content of the Internet Explorer address Bar (the URL)
The API function GetWindowText do not returns the text entered in an Edit
box. We have to use another way to do that. In this case, I used the ClipBoar
as a 'middleware' to transfer the text among IE and this app.
This app was created using the IE 5.5. If the IE object names of your version
are not the same as used here, then use the WinSight32 to locate the correct
names.
Copyright?2001 DelphiBahia
Hugo Novaes
www.delphibahia.eti.br
hugo.novaes@delphibahia.eti.br
}
//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;