Using CAxWindow to host a browser control 
Author Message
 Using CAxWindow to host a browser control

We're writing an application, not using any MFC or really much Windows-specific
code at all.

A while back we wanted to include a WebBrowser as a part of our client executable.

After getting advice from people more in-the-know on this topic, I approached the
problem by creating a CAxWindow, connecting that to a window I'd created thru
Attach, then creating a WebBrowser with CreateControlEx.  All well & good.

Problem is, I would really like to have my own code get connected somehow as the
DWebBrowserEvents2 for my Web browser control - I'd like to be alerted when
certain things happen.  In particular, I *really* need to be alerted if the user
does something within the browser that kills the browser window ( I guess you can
have a web page that, on user button-click, kills the whole control and
everything ).

So how do I make the connection?  I don't see anything in the IWebBrowser2
interface where I can hook in a DWebBrowserEvents2.  At that point I'm guessing
the browser control queries for the interface, so I've tried figuring out how to
make some class that inherits from CAxWindow, supports the DWebBrowserEvents2
interface, and knows how to give out it's DWebBrowserEvents2 when the window is
queried, can't figure how to do that either.

I am a new to this bulletin board: if this is not the appropriate place for such
a question, I apologize.  If answers could be e-mailed to me as well that would
be great.

Thanks
Doug



Sat, 30 Aug 2003 08:00:07 GMT  
 Using CAxWindow to host a browser control
In general, see IDispEventImpl, IDispEventImpl::DispEventAdvise. See
ATLEventHandling for a sample of handling events in ATL.

In particular, see KB Article Q253219 "PRB: WebBrowser Control Disappears
When Script Calls window.close()" at

http://support.microsoft.com/support/kb/articles/Q253/2/19.ASP

--
With best wishes,
    Igor Tandetnik


We're writing an application, not using any MFC or really much
Windows-specific
code at all.

A while back we wanted to include a WebBrowser as a part of our client
executable.

After getting advice from people more in-the-know on this topic, I
approached the
problem by creating a CAxWindow, connecting that to a window I'd created
thru
Attach, then creating a WebBrowser with CreateControlEx.  All well & good.

Problem is, I would really like to have my own code get connected somehow as
the
DWebBrowserEvents2 for my Web browser control - I'd like to be alerted when
certain things happen.  In particular, I *really* need to be alerted if the
user
does something within the browser that kills the browser window ( I guess
you can
have a web page that, on user button-click, kills the whole control and
everything ).

So how do I make the connection?  I don't see anything in the IWebBrowser2
interface where I can hook in a DWebBrowserEvents2.  At that point I'm
guessing
the browser control queries for the interface, so I've tried figuring out
how to
make some class that inherits from CAxWindow, supports the
DWebBrowserEvents2
interface, and knows how to give out it's DWebBrowserEvents2 when the window
is
queried, can't figure how to do that either.

I am a new to this bulletin board: if this is not the appropriate place for
such
a question, I apologize.  If answers could be e-mailed to me as well that
would
be great.

Thanks
Doug



Sat, 30 Aug 2003 08:10:59 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Serious problem with using AtlAxWin to host Internet Explorer Browser Control

2. PRB: Hosting ActiveX document using CAxWindow

3. Tabs does not work in webbrowser control hosted by CAxWindow in CAxDialogImpl

4. CAxWindow - Hosted Control's Window Handle

5. How to get a CAxWindow Hosted Control to draw when the Window is Not visible

6. CAxWindow for hosting ActiveX Controls

7. Hosting WebBrowser control in ATL CAxWindow

8. mfc control instantiated in atl composite control using CAxWindow wont destruct

9. Retrieve IHtmlDocument2 interface from a hosted web browser control

10. How to host web browser control in sdi app with straight com

11. ActiveX control causing host browser to navigate

12. Access violation when destroying CAxWindow hosting MSHTML

 

 
Powered by phpBB® Forum Software