Link to home
Start Free TrialLog in
Avatar of DixieKMan
DixieKManFlag for United States of America

asked on

Browser Enumeration

Hello All,
 
I have a question regarding enumeration of explorer windows.

I currently can enumerate all open explorer windows with SHDocVw.ShellWindows, however, once enumerated, how can I track those specific windows, as I cannot store the hWnd. (see below)

Dim SWs As New SHDocVw.ShellWindows
Dim IE As SHDocVw.InternetExplorer

        For Each IE In SWs
        'SWs enumerate the Shell Windows
            Set Doc = IE.Document
            If TypeOf Doc Is HTMLDocument Then
                  List1.AddItem IE.LocationURL
            End If
        Next

the locationURL and locationName are dynamic and will change after any navigation.

I need to open an internet explorer and track that specific explorer, even if another is opened with the same address.

Any help would be most appreciated,

DixieKMan
 
Avatar of Asta Cu
Asta Cu
Flag of United States of America image

Not my area of expertise, and have asked for additional Expert insights here; perhaps this is a starting point, though.

API: Read/Set Internet Explorer URL from code
http://www.mvps.org/access/api/api0051.htm

":0) Asta
Avatar of DixieKMan

ASKER

Dear astaec,

Thank You for such rapid response, however the class listed in your comment uses the hWnd property to differentiate multiple browsers. But, according to MSDN

:Quote from Hwnd Property MNDN ===========================

The Microsoft Windows operating environment identifies each form and control in an application by assigning it a handle, or hWnd. The hWnd property is used withWindows API calls. Many Windows operating environment functions require the hWnd of the active window as an argument.

Note   Because the value of this property can change while a program is running, never store the hWnd value in a variable.

:========================================================

This is my problem, I can retrieve the hWnd from the initial enumeration, however if it is an arbitrary pointer and subject to change, I cannot use it. I need a way to definitively single out a browser and track it regardless of its navigation URL. Perhaps this will clarify my issue.

Thank You again,
DixieKMan
Thanks a bunch for expounding; I'm confident this will help in terms of added clarification for others.  I have sent this link to another Expert in the hopes he'll have a chance to stop by and help you further.  I'm not well versed in this area and am at work, but will check back later today and do some additional research, if still unresolved.

":0) Asta

The IWebBrowser2 interface has a property named HWND (or get_HWND or GetHwnd, depending upon how you want to look at it).  That should return the unique HWND for the top-level browser window that is hosting the document.  Track that rather than the URL location or other impermanent attribute.

-- Dan
I will keep uping the points until someoone gets this ;)

Dan, please see the above statement regarding the hWnd property. I can get the hWnd from the initial enumeration with the .hWnd property in SHDocVw.ShellWindows. My main concern is the potential dynamic traits of the hWnd property itself.

Thanx for your input,

DixieKMan
The HWND of a particular window is PERMANENT.  It will not change unless the window is closed.  That quote from MSDN makes no sense.

>>if it is an arbitrary pointer and subject to change, I cannot use it

It is not an arbitrary pointer.  It is not a pointer at all, it is a unique handle.  Anyway, If you are worried about it changing value (lol, it wont't) then all you need to do is keep track of the object and use the object's HWND property.

-- Dan
I am afraid that I am at a loss her, and am in need of arbitration.

First off, I thank you both sincerely for your input into my particular problem.

astaec: Your initial suggestion contained the answer to my question, as the example class shown used the hWnd property to differentiate between browser instances. To be honest, it was my first choice until the MSDN tossed a flag on the play.


DanRollins: Your "matter of fact" presentation placed any potential doubts to rest, and upon review of both of your exceptional records, feel my issue resolved. I shall proceed with my line of codinging as prescribed.

My problem now is point distribution. I think you both played equally in this issue, and feel you both should recieve points for this question. I appeal the moderator of this topic for options. I will raise the point value to 90 for ease in division, and would like both parties to recieve half. Can I do something to this nature?

I will await reply before proceeding.

DixieKMan
ASKER CERTIFIED SOLUTION
Avatar of DanRollins
DanRollins
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thank You Dan, question posted.

DixieKMan
Avatar of Mindphaser
Mindphaser

DixieKMan

You want to reward points to these experts:

I reduced the points to 45 and refunded the rest. Please accept one experts comment as an answer and post a 45p question for the other expert with a title like : "Points for xxx" and a body "For your help in  ."

** Mindphaser - Community Support Moderator **
Thank You again.

DixieKMan
Thank you, DixieKMan and Mindphaser.
":0) Asta