Solved

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

Posted on 2004-08-16
8
1,285 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
VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

 
LVL 3

Accepted Solution

by:
Belthazor earned 500 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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
C# Error - Add Failed 12 87
This code tracks birthdays 3 73
Plain Text Editor for iPad 6 75
Please help| Getting the syntax error in below query. 2 57
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

810 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