🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #14887

Re: Need help with this code...(2)

#14887
From: micheal davis
Date: Tue, 29 Jul 2003 18:54
93 lines
3831 bytes
Thanks remy, the code just works great...and I will check the link you
provided me as well.

Now this code retrieves the typed URL of the active IE window, and I am
trying to get the URL's of all opened IE windows then add them to a listbox
on my form...so I found EnumWindows function and I tried to use it with the
code you translated although I can't make it work and all I get in result is
the active window url being typed in my list box for like 50 times and I
test while having 3 IE windows only

thank your for your patience and support

the code for EnumWindows

BOOL CALLBACK MyWindowsProc( HWND hwnd, LPARAM lParam )
{
   Form1->GetURL();

   BOOL ret = TRUE;
   return ret;
}
//--------------------------------------------------------------------------
-
void __fastcall TForm1::GetWindowsInfo()
{

   if (!EnumWindows((WNDENUMPROC)MyWindowsProc, (LPARAM)UrlListBox->Items))
//I am adding the retrieved url's in a list box
   {       ShowMessage("Error occured while EnumWindows");
   }
}
//--------------------------------------------------------------------------
-

and I added the following line to the code below...

"Remy Lebeau (TeamB)" <gambit47@yahoo.com> wrote in message
news:3f26be21@newsgroups.borland.com...
>
> "micheal davis" <micheal_davis@hotmail.com> wrote in message
> news:3f268dd9@newsgroups.borland.com...
>
> > I enclosed the Pascal code and the C++ code after I trying to
translate...
>
>     AnsiString __fastcall GetText(HWND WindowHandle)
>     {
>         int txtLength;
>         AnsiString buffer;
>
>         txtLength = ::SendMessage(WindowHandle, WM_GETTEXTLENGTH, 0, 0) +
1;
>         buffer.SetLength(txtLength);
>         ::SendMessage(WindowHandle, WM_GETTEXT, txtLength,
> (LPARAM)buffer.c_str());
>

UrlListBox->Items->Add(buffer);

>         return buffer;
>     }
>
>     AnsiString __fastcall GetURL()
>     {
>         HWND ie, worker, toolbar, comboboxex, combo, edit;
>
>         ie = ::FindWindow("IEFrame", NULL);
>         worker = ::FindWindowEx(ie, 0, "WorkerA", NULL);
>         toolbar = ::FindWindowEx(worker, 0, "ReBarWindow32", NULL);
>         comboboxex = ::FindWindowEx(toolbar, 0, "ComboBoxEx32", NULL);
>         combo = ::FindWindowEx(comboboxex, 0, "ComboBox", NULL);
>         edit = ::FindWindowEx(combo, 0, "Edit", NULL);
>
>         return GetText(edit);
>     }
>
>     void __fastcall TForm1::Button1Click(TObject *Sender)
>     {
>         ShowMessage(GetURL());
>     }
>
> BTW, there is a much easier way to obtain the current URL from IE.  Use
DDE
> instead, for example:
>
>
http://groups.google.com/groups?q=borland+remy+internet+explorer+dde&hl=en&l
> r=&ie=UTF-8&oe=UTF-8&selm=3e1e2b12%241%40newsgroups.borland.com&rnum=1
>
>
> Gambit
>
>
Technical Details
Message-ID: <3f26c2cc@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-04!sn-xit-06!sn-xit-09!supernews.com!news.maxwell.syr.edu!skynet.be!skynet.be!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <3f268dd9@newsgroups.borland.com> <3f26be21@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10cc67,58a7894f639848fb
X-Google-Attributes: gid10cc67,public
X-Google-ArrivalTime: 2003-07-29 12:10:41 PST
From: "micheal davis" <micheal_davis@hotmail.com>
Newsgroups: borland.public.cppbuilder.nativeapi
References: <3f268dd9@newsgroups.borland.com> <3f26be21@newsgroups.borland.com>
Subject: Re: Need help with this code...(2)
Date: Tue, 29 Jul 2003 10:54:03 -0800
Lines: 95
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.72
Message-ID: <3f26c2cc@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1059504844 62.135.27.72 (29 Jul 2003 11:54:04 -0700)
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-04!sn-xit-06!sn-xit-09!supernews.com!news.maxwell.syr.edu!skynet.be!skynet.be!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail