🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

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

#14896
From: Remy Lebeau (TeamB)
Date: Tue, 29 Jul 2003 22:27
74 lines
4151 bytes
"micheal davis" <micheal_davis@hotmail.com> wrote in message
news:3f26ec37@newsgroups.borland.com...

> I think I didn't understand you well...when you said I
> must tell GetURL function which window it must look
> to each time...if this is what you meant then I believe
> there is misunderstanding...

You are still misunderstanding the entire procedure to accomplishing what
you are asking for.

> when I tried to use EnumWindows function... I was
> looking for API function that I can use to search for all
> active IE open windows and with the GetURL code...

There is no such pre-made function.  You have to locate the URLs manually.
I have already given you all of the code for doing that.  The purpose of
EnumWindows() is to loop through all of the currently active top-level
windows on the desktop, whatever they happen to be.  However, your previous
GetURL() function was only looking specific at the first active IE window
every time it is called.  There is no point in looping through all of the
available windows at all if you are going to be looking at the same window
each time.  So I adjusted your GetURL() function so that it would grab the
URL from a specific window that is passed to it instead of looking for one.
That way, the EnumWindows() code can loop through all of the active windows,
figure out which ones are IE windows, and then call GetURL() to get the URL
from each one.

> my program will automatically add to my listbox all
> the URLs in ALL active IE opened windows...
> NOT a specific one....

If you actually study the code I have given you, you will see that it does
do exactly what you are asking for.  It does look for *all* of the active IE
windows, and does retreive the URLs of *all* of the active IE windows.  I
think you need to read up more on how EnumWindows() works in general, it
seems to me that you are under the impression that the callback function
will only be called for a single window, which in fact it will be called
once for each active top-level window instead.

> Anyway I copied your code as is and I tried to run it by
> calling and unfortunately it didn't retrieve any URL's from
> the active IE opened windows...

It works fine when I try it.  However, there was a small typo in my previous
example.  Change this line:

    ((TListBox*)lParam)->Items->Add(GetURL(hwnd));

To this instead:

    ((TStrings*)lParam)->Add(GetURL(hwnd));

Also, just as a side note, when calling EnumWindows(), you sould call the
ListBox's BeginUpdate() and EndUpdate() methods as well:

    void __fastcall TForm1::GetWindowsInfo()
    {
        UrlListBox->Items->Clear();
        UrlListBox->Items->BeginUpdate();
        try
        {
            if( !EnumWindows((WNDENUMPROC)MyWindowsProc,
(LPARAM)UrlListBox->Items) )
                ShowMessage("Error occured while EnumWindows");
        }
        __finally {
            UrlListBox->Items->EndUpdate();
        }
    }


Gambit
Technical Details
Message-ID: <3f26f381$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-03!sn-xit-01!sn-xit-09!supernews.com!news.maxwell.syr.edu!small1.nntp.aus1.giganews.com!border1.nntp.aus1.giganews.com!nntp.giganews.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail
References: <3f268dd9@newsgroups.borland.com> <3f26be21@newsgroups.borland.com> <3f26c2cc@newsgroups.borland.com> <3f26d436$1@newsgroups.borland.com> <3f26ec37@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 15:29:00 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> <3f26d436$1@newsgroups.borland.com> <3f26ec37@newsgroups.borland.com>
Subject: Re: Need help with this code...(2)
Date: Tue, 29 Jul 2003 15:27:37 -0700
Lines: 76
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: <3f26f381$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1059517313 207.175.226.26 (29 Jul 2003 15:21:53 -0700)
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-03!sn-xit-01!sn-xit-09!supernews.com!news.maxwell.syr.edu!small1.nntp.aus1.giganews.com!border1.nntp.aus1.giganews.com!nntp.giganews.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail