Solved

events in an embedded webbrowser control

Posted on 1998-12-01
7
324 Views
Last Modified: 2013-11-20
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
0
Comment
Question by:catwiz
  • 4
  • 2
7 Comments
 

Author Comment

by:catwiz
Comment Utility
Edited text of question
0
 
LVL 2

Expert Comment

by:cramer091498
Comment Utility
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(CWebBrowser, 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::BeforeNavigate2.

I hope this helps.

0
 

Author Comment

by:catwiz
Comment Utility
this makes no difference
0
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 

Author Comment

by:catwiz
Comment Utility
Adjusted points to 250
0
 
LVL 2

Accepted Solution

by:
cramer091498 earned 250 total points
Comment Utility
Sorry, what I neglected to say was the AFX_IDW_PANE_FIRST should be replaced with the id that you use to create the WEB Browser control with.  Check the last parameter of your webBrowser::Create function and set it to this value.

Hope this helps.
0
 

Author Comment

by:catwiz
Comment Utility
Thats excellent. Thanks; you're great!
0
 

Expert Comment

by:kibi
Comment Utility
Thank you thank you thank you thank you thank you!
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.

728 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now