How to get IE's Window Handle

  • Thread starter Thread starter Polaris
  • Start date Start date
P

Polaris

Hello Experts:

I'm writing an ActiveX control which will be loaded by the IE. How can I get
the IE's Window Handle (HWND) within the ActiveX control ?

Thanks in Advance !
Polaris
 
What do you mean by loaded by IE? - As a Browser Helper? As a toolbar or
loaded within a html document?

For a BHO you have to implement IObjectWithSite and IDeskBand (search msdn
on these keywords)

For a toolbar usually you have a satellite BHO above or you can find the top
window when the toolbar is redrawn (which will always be the iexplore.exe
window). But be careful with MSN Search bar tabbed browsing when using the
top window method as each tab is actually a separate IE window!.

There are samples on msdn in the ActiveX gallery. The Stock ticker was
written in VB6
Also search msdn for Band Objects.
 
Polaris said:
I'm writing an ActiveX control which will be loaded by the IE. How
can I get the IE's Window Handle (HWND) within the ActiveX control ?

IOleInPlaceSite::GetWindow gives you the parent widow you are hosted on.

If you want the top-level window of the browser, see KB Article KB257717
"How To Retrieve the Top-Level IWebBrowser2 Interface from an ActiveX
Control". Once you have IWebBrowser2 pointer, use its get_HWND method.
--
With best wishes,
Igor Tandetnik

With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925
 
Back
Top