D
dngjzx
Unregistered / Unconfirmed
GUEST, unregistred user!
//取IE标题和地址栏函数
function EnumChildWindowsProc(hwnd: Integer; lparam: Longint): Boolean; stdcall;
var
buffer: array[0..255] of char;
begin
Result := True;
GetClassName(hwnd,buffer,256);
if StrPas(Buffer)='Edit' then
begin
SendMessage(hwnd,WM_GETTEXT,256,lparam);
Result:=False;
end;
end;
procedure TForm1.FormActivate(Sender: TObject);
var
hwnd: Integer;
buffer: array[0..255] of char;
begin
hwnd := FindWindow('IEFrame',nil);
if hwnd<> 0 then
begin
EnumChildWindows(hwnd,@EnumChildWindowsProc,Integer(@buffer[0]));
edit2.Text:=(StrPas(buffer));
GetWindowText(hwnd,buffer,51);//取标题栏的前50个字符
edit1.Text:=(strpas(buffer));
end;
end;
这样用GetWindowText得到的信息是整个标题栏的信息,比如
http://www.delphibox.com - Microsoft Internet Explorer
如何只取http://www.delphibox.com呢?
function EnumChildWindowsProc(hwnd: Integer; lparam: Longint): Boolean; stdcall;
var
buffer: array[0..255] of char;
begin
Result := True;
GetClassName(hwnd,buffer,256);
if StrPas(Buffer)='Edit' then
begin
SendMessage(hwnd,WM_GETTEXT,256,lparam);
Result:=False;
end;
end;
procedure TForm1.FormActivate(Sender: TObject);
var
hwnd: Integer;
buffer: array[0..255] of char;
begin
hwnd := FindWindow('IEFrame',nil);
if hwnd<> 0 then
begin
EnumChildWindows(hwnd,@EnumChildWindowsProc,Integer(@buffer[0]));
edit2.Text:=(StrPas(buffer));
GetWindowText(hwnd,buffer,51);//取标题栏的前50个字符
edit1.Text:=(strpas(buffer));
end;
end;
这样用GetWindowText得到的信息是整个标题栏的信息,比如
http://www.delphibox.com - Microsoft Internet Explorer
如何只取http://www.delphibox.com呢?