Article View: borland.public.cppbuilder.nativeapi
Article #14873Need help with this code...
From: micheal davis
Date: Tue, 29 Jul 2003 15:04
Date: Tue, 29 Jul 2003 15:04
44 lines
3367 bytes
3367 bytes
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;vartxtLength : 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;varie,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);beginshowmessage(GetURL);end;My C++ Codevoid __fastcall
TForm1::Button1Click(TObject *Sender){
ShowMessage(GetURL());}//---------------------------------------------------
------------------------AnsiString __fastcall TForm1::GetText(HWND
WindowHandle){ int txtLength; txtLength = SendMessage(WindowHandle,
WM_GETTEXTLENGTH, 0, 0)+1; 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);}//-----------------------------------------------------------
----------------thanks all for your help...best regards
Technical Details
Message-ID:
<3f268cfa@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!newsfeed.news2me.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,a734be1e1c24cfbf,start X-Google-Attributes: gid10cc67,public X-Google-ArrivalTime: 2003-07-29 08:10:23 PST From: "micheal davis" <micheal_davis@hotmail.com> Newsgroups: borland.public.cppbuilder.nativeapi Subject: Need help with this code... Date: Tue, 29 Jul 2003 07:04:26 -0800 Lines: 46 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: <3f268cfa@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1059491066 62.135.27.49 (29 Jul 2003 08:04:26 -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!newsfeed.news2me.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