Article View: borland.public.cppbuilder.nativeapi
Article #14874Need help with this code...(2)
From: micheal davis
Date: Tue, 29 Jul 2003 15:08
Date: Tue, 29 Jul 2003 15:08
88 lines
3526 bytes
3526 bytes
Sorry for repeating my message please discard my first one...thanks..
Hi all,
I've got this Pascal code that enable grabbing URL from any IE window, but
it seems not to work after I tried to translate it, so can some one help me
PLEASE translate this code.
I enclosed the Pascal code and the C++ code after I trying to translate...
The Pascal Code:
Function GetText(WindowHandle: hwnd):string;
var
txtLength : integer;
buffer: string;
begin
TxtLength := SendMessage(WindowHandle, WM_GETTEXTLENGTH, 0, 0);
txtlength := txtlength + 1;
setlength (buffer, txtlength);
sendmessage (WindowHandle,wm_gettext, txtlength, longint(@buffer[1]));
result := buffer;
end;
function GetURL:string;
var
ie,toolbar,combo,
comboboxex,edit,
worker,toolbarwindow:hwnd;
begin
ie := FindWindow(pchar('IEFrame'),nil);
worker := FindWindowEx(ie,0,'WorkerA',nil);
toolbar := FindWindowEx(worker,0,'rebarwindow32',nil);
comboboxex := FindWindowEx(toolbar, 0, 'comboboxex32', nil);
combo := FindWindowEx(comboboxex,0,'ComboBox',nil);
edit := FindWindowEx(combo,0,'Edit',nil);
toolbarwindow := FindWindowEx(comboboxex, 0, 'toolbarwindow32', nil);
result := GetText(edit);
{-------------------------------------------------------}
procedure TForm1.Button1Click(Sender: TObject);
begin
showmessage(GetURL);
end;
the C++ Code..
void __fastcall TForm1::Button1Click(TObject *Sender)
{
ShowMessage(GetURL());
}
//--------------------------------------------------------------------------
-
AnsiString __fastcall TForm1::GetText(HWND WindowHandle)
{
int txtLength;
txtLength = SendMessage(WindowHandle, WM_GETTEXTLENGTH, 0, 0)+1;
ShowMessage(txtLength);
char *buffer = new char[txtLength];
SendMessage(WindowHandle, WM_GETTEXT, (WPARAM)txtLength, (LPARAM)buffer);
return buffer;
}
//--------------------------------------------------------------------------
-
AnsiString __fastcall TForm1::GetURL()
{
HWND ie,toolbar,combo,comboboxex,edit,worker,toolbarwindow;
ie = FindWindow("IEFrame",NULL);
worker = FindWindowEx(ie,NULL,"WorkerA",NULL);
toolbar = FindWindowEx(worker,NULL,"rebarwindow32",NULL);
comboboxex = FindWindowEx(toolbar,NULL,"comboboxex32", NULL);
combo = FindWindowEx(comboboxex,NULL,"ComboBox",NULL);
edit = FindWindowEx(combo,NULL,"Edit",NULL);
toolbarwindow = FindWindowEx(comboboxex,NULL,"toolbarwindow32", NULL);
return GetText(edit);
}
//--------------------------------------------------------------------------
-
Technical Details
Message-ID:
<3f268dd9@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-04!sn-xit-01!sn-xit-08!supernews.com!news.tele.dk!news.tele.dk!small.news.tele.dk!tiscali!newsfeed1.ip.tiscali.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10cc67,58a7894f639848fb,start X-Google-Attributes: gid10cc67,public X-Google-ArrivalTime: 2003-07-29 08:10:26 PST From: "micheal davis" <micheal_davis@hotmail.com> Newsgroups: borland.public.cppbuilder.nativeapi Subject: Need help with this code...(2) Date: Tue, 29 Jul 2003 07:08:09 -0800 Lines: 90 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1158 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 NNTP-Posting-Host: 62.135.27.49 Message-ID: <3f268dd9@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1059491289 62.135.27.49 (29 Jul 2003 08:08:09 -0700) Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-04!sn-xit-01!sn-xit-08!supernews.com!news.tele.dk!news.tele.dk!small.news.tele.dk!tiscali!newsfeed1.ip.tiscali.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail