catwiz
asked on
events in an embedded webbrowser control
I have created a webbrowser control and added it to my MFC app. Everything works well; I can send Navigate2 commands and move to pages.
But I need to get the BeforeNavigate2 event. I added the code for the function but it never gets called. Do I need to add some kind of sink code?
I have an example of a dialog based app and it's easy to trap the event there.
I'm using Visual C++ 5.0
Actual code would be appreciated.
thanks
Catwiz
But I need to get the BeforeNavigate2 event. I added the code for the function but it never gets called. Do I need to add some kind of sink code?
I have an example of a dialog based app and it's easy to trap the event there.
I'm using Visual C++ 5.0
Actual code would be appreciated.
thanks
Catwiz
You need to declare an event sink for your project.
The header file for the class which is the wrapper for the browser should have DECLARE_EVENTSINK_MAP()
and something like this should appear in the cpp file.
BEGIN_EVENTSINK_MAP(CWebBr owser, CView)
ON_EVENT(CWebBrowser, AFX_IDW_PANE_FIRST, 250 /* BeforeNavigate2 */, BeforeNavigate2, VTS_DISPATCH VTS_PVARIANT VTS_PVARIANT VTS_PVARIANT VTS_PVARIANT VTS_PVARIANT VTS_PBOOL)
END_EVENTSINK_MAP()
This code was based on the CHtmlView class supplied with Microsoft's VC++ 6.0
Then you should be able to use events just like in any other MFC project.
The function called when a BeforeNavigate2 event happens is CWebBrowser::BeforeNavigat e2.
I hope this helps.
The header file for the class which is the wrapper for the browser should have DECLARE_EVENTSINK_MAP()
and something like this should appear in the cpp file.
BEGIN_EVENTSINK_MAP(CWebBr
ON_EVENT(CWebBrowser, AFX_IDW_PANE_FIRST, 250 /* BeforeNavigate2 */, BeforeNavigate2, VTS_DISPATCH VTS_PVARIANT VTS_PVARIANT VTS_PVARIANT VTS_PVARIANT VTS_PVARIANT VTS_PBOOL)
END_EVENTSINK_MAP()
This code was based on the CHtmlView class supplied with Microsoft's VC++ 6.0
Then you should be able to use events just like in any other MFC project.
The function called when a BeforeNavigate2 event happens is CWebBrowser::BeforeNavigat
I hope this helps.
ASKER
this makes no difference
ASKER
Adjusted points to 250
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thats excellent. Thanks; you're great!
Thank you thank you thank you thank you thank you!
ASKER