Article View: borland.public.cppbuilder.nativeapi
Article #14889Re: Need help with this code...(2)
From: Remy Lebeau (TeamB)
Date: Tue, 29 Jul 2003 20:14
Date: Tue, 29 Jul 2003 20:14
64 lines
2943 bytes
2943 bytes
"micheal davis" <micheal_davis@hotmail.com> wrote in message
news:3f26c2cc@newsgroups.borland.com...
> BOOL CALLBACK MyWindowsProc( HWND hwnd, LPARAM lParam )
> {
> Form1->GetURL();
>
> BOOL ret = TRUE;
> return ret;
> }
Even though you are enumerating windows, you are still only looking at the
active IE window when retreiving the actual URL. That is why you are seeing
the same URL repeated over and over. You need to tell GetURL() which actual
window to look at each time.
Try this instead:
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());
return buffer;
}
AnsiString __fastcall GetURL(HWND IEWindowHandle)
{
HWND worker, toolbar, comboboxex, combo, edit;
worker = ::FindWindowEx(IEWindowHandle, 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);
}
BOOL CALLBACK MyWindowsProc( HWND hwnd, LPARAM lParam )
{
char buffer[12] = {0};
::GetClassName(hwnd, buffer, 12);
if( StrComp(buffer, "IEFrame") == 0 )
((TListBox*)lParam)->Items->Add(GetURL(hwnd));
return TRUE;
}
void __fastcall TForm1::GetWindowsInfo()
{
UrlListBox->Items->Clear();
if( !EnumWindows((WNDENUMPROC)MyWindowsProc,
(LPARAM)UrlListBox->Items) )
ShowMessage("Error occured while EnumWindows");
}
Gambit
Technical Details
Message-ID:
<3f26d436$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-05!sn-xit-08!supernews.com!news-out.visi.com!petbe.visi.com!eusc.inter.net!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<3f268dd9@newsgroups.borland.com> <3f26be21@newsgroups.borland.com> <3f26c2cc@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 13:10:36 PST From: "Remy Lebeau \(TeamB\)" <gambit47@yahoo.com> Newsgroups: borland.public.cppbuilder.nativeapi References: <3f268dd9@newsgroups.borland.com> <3f26be21@newsgroups.borland.com> <3f26c2cc@newsgroups.borland.com> Subject: Re: Need help with this code...(2) Date: Tue, 29 Jul 2003 13:14:14 -0700 Lines: 66 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.1106 NNTP-Posting-Host: 207.175.226.26 Message-ID: <3f26d436$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1059509302 207.175.226.26 (29 Jul 2003 13:08:22 -0700) Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-05!sn-xit-08!supernews.com!news-out.visi.com!petbe.visi.com!eusc.inter.net!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail