Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2004-08-16
8
Medium Priority
?
1,295 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Build and deliver software with DevOps

A digital transformation requires faster time to market, shorter software development lifecycles, and the ability to adapt rapidly to changing customer demands. DevOps provides the solution.

 
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

Build and deliver software with DevOps

A digital transformation requires faster time to market, shorter software development lifecycles, and the ability to adapt rapidly to changing customer demands. DevOps provides the solution.

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.
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

721 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