Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

How can I get the handle to the client part of IE

Posted on 2004-08-16
8
Medium Priority
?
1,296 Views
Last Modified: 2008-01-09
Hi all,

Looking for a way that from a program I can (a) open an instance of IE and (b) get the handle to the "client part" of that open IE web browser.  The client part is the area in which the web page is rendered.

Would like to understand how to do this in either VB.NET or C#.NET.

Can anyone help ?

Thanks,

John
0
Comment
Question by:trzesniakj
  • 3
  • 2
  • 2
  • +1
8 Comments
 
LVL 8

Expert Comment

by:adg080898
ID: 11815551
Hmm. Don't know VB that well, but you could do something like this:

x = CreateObject("InternetExplorer.Application")

x.document.body = "<html><head>From VB</head><body>Hello VB COM world</body></html>"

messagebox "Click OK to close"

Does that work?
0
 

Author Comment

by:trzesniakj
ID: 11817398
No.  But thank you for taking time to respons.

I'm looking to get the actual window "handle" (unique window identifier in the OS for each window and control created...and it's an integer) to the part of the browser that renders the web page for something else I need to do.

Thanks,

John
0
 
LVL 3

Expert Comment

by:Belthazor
ID: 11817567
Hi,
all you ned is the Windows Caption and an API Function:

---------------------------------------------------------------------------------------------
Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hwndParent As Long, ByVal hwndChildAfter As Long, ByVal pszClass As String, ByVal lpszWindow As String) As Long

Dim IEWindowHandle As Long, IECaption as String
IEWindowHandle  = 0
IECaption = "Google - Microsoft Internet Explorer" 'Must be exact

IEWindowHandle = FindWindowEx(IEWindowHandle , 0, vbNullString, IECaption)
If IEWindowHandle = 0 Then
   'Error handling
Else
   'You found the Handle, saved in IEWindowHandle
End If
---------------------------------------------------------------------------------------------
and by the way .... a windows handle has always 'Long' datatype

good luck
Belthazor

0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 3

Accepted Solution

by:
Belthazor earned 2000 total points
ID: 11817630
Hi,
in case you need some sample code how to get the client area: you can just use FindWindowEx again:

Dim ClientArea as Long
ClientArea = 0

 'You found the Handle, saved in IEWindowHandle
FindWindowEx(IEWindowHandle, 0, "Shell DocObject View", "")

Explanations:
This is the declaration of FindWindowEx:

FindWindowEx(HWND hwndParent, HWND hwndChildAfter, LPCTSTR lpszClass, LPCTSTR lpszWindow)

hwndParent: the IEWindowHandle we found above
hwndChildAfter: search all Windows within the IE Dialog
lpszClass: The class of the Windows, as you see above it is "Shell DocObject View". You can find out things like this using the Spy++ tool of Microsoft, which is includid in Visual Studio 6. (If you dont have it, download "spyxx.exe", "spyhk55.dll" and "spyxx.hlp" from http://www.et.utt.ro/public/ProgLangs/VisualStudio6/common/tools/ )
lpszWindow: Window's Caption. According to Spy++ the Caption of the Client Area is ""

Hope you'll get it to work
Belthazor
0
 
LVL 3

Expert Comment

by:Stimphy
ID: 11817921
Try This:

Reference Microsoft Internet Controls

Dim IE As InternetExplorer
Set IE = New InternetExplorer
IE.Navigate2 "www.google.com"
IE.Visible = True
MsgBox IE.hWnd

Here is are some links to microsoft that may be useful.

http://support.microsoft.com/default.aspx?scid=kb;EN-US;238313
http://www.microsoft.com/mind/0898/dom.asp

Regaurds,
Dave
0
 
LVL 8

Expert Comment

by:adg080898
ID: 11818056
My Spy++ shows the class of the client area is "Internet Explorer_Server" and the title blank.
0
 
LVL 3

Expert Comment

by:Belthazor
ID: 11818066
@adq: Mine too, as Child of "Shell DocObject View"
@John: Depending on what you are planning to do: trial and error with the classes
0
 

Author Comment

by:trzesniakj
ID: 11824734
Thank you all so much.  I have to play with it a little bit.  But I think I can take it from here !

Thanks,

John
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
What do responsible coders do? They don't take detrimental shortcuts. They do take reasonable security precautions, create important automation, implement sufficient logging, fix things they break, and care about users.
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
Loops Section Overview

926 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question