Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Getting to document dom from hwnd of IE window

69 views
Skip to first unread message

RLoski

unread,
Jan 14, 2008, 12:26:13 PM1/14/08
to
I can get the hwnd for the IE window. I am assuming that a particular page
is displayed in that IE window and I want to call a javascript routine that
is defined on that page. How would I do this?

This is not my architecture.


Current version of IE: 6, OS: Windows XP.
--
Russel Loski, MCSD.Net

Larry Serflaten

unread,
Jan 14, 2008, 4:36:47 PM1/14/08
to

"RLoski" <RLo...@discussions.microsoft.com> wrote

> I can get the hwnd for the IE window. I am assuming that a particular page
> is displayed in that IE window and I want to call a javascript routine that
> is defined on that page. How would I do this?

I've never tried that before, but to help point the way, I'll suggest two things,

1. Get an object reference to the IE window:

Function IERef(Find_hWnd As Long) As InternetExplorer
' REFERENCE Microsoft Internet Controls for:
Dim SW As ShellWindows
Dim IE As InternetExplorer

Set SW = New ShellWindows

For Each IE In SW
If TypeName(IE.Document) = "HTMLDocument" Then
If IE.hWnd = Find_hWnd Then
Set IERef = IE
Exit Function
End If
Next
End Function


2. Use the DOM ( Document.parentWindow.execScript) to call your script.

LFS


Steve Easton

unread,
Jan 14, 2008, 4:57:01 PM1/14/08
to
However, with IE 7 and tabbed windows, one hwnd can have several pages.
The user will have to check each hwnd
for each LocationName and / or LocationURL
to ensure he has the correct page.


--

Steve Easton

"Larry Serflaten" <serf...@usinternet.com> wrote in message news:u3mQeVvV...@TK2MSFTNGP06.phx.gbl...

RLoski

unread,
Jan 15, 2008, 5:20:04 AM1/15/08
to
Thank you for your point. I will make sure to alert my client about this.


--
Russel Loski, MCSD.Net

mayayana

unread,
Jan 15, 2008, 9:27:37 AM1/15/08
to
If you run into any problems, you might find this helpful
(in addition to Spy++) -

www.jsware.net/jsware/vbcode.php3#shlop

The download is sample code and lots of notes
about accessing Document objects and ShellFolderView
objects from folder windows, Document objects
from HTAs, etc. Basically, you can get hold of a
Document from any window of class:

"Internet Explorer_Server"

But in some cases it might be necessary to walk
a process "window tree" to sort them out.

Kevin Provance

unread,
Feb 1, 2008, 9:13:15 AM2/1/08
to
Perhaps this: http://support.microsoft.com/kb/249232?

How to get IHTMLDocument2 from a HWND

"RLoski" <RLo...@discussions.microsoft.com> wrote in message
news:8D3B7C9D-8806-4966...@microsoft.com...

mayayana

unread,
Feb 1, 2008, 10:01:06 AM2/1/08
to

> Perhaps this: http://support.microsoft.com/kb/249232?
>
> How to get IHTMLDocument2 from a HWND
>
The OP probably wouldn't need that, but in any case,
the VB version is included and explained in the code
I already linked to.


0 new messages