Solved

events in an embedded webbrowser control

Posted on 1998-12-01
7
389 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
7 Comments
 

Author Comment

by:catwiz
ID: 1325574
Edited text of question
0
 
LVL 2

Expert Comment

by:cramer091498
ID: 1325575
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
ID: 1325576
this makes no difference
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:catwiz
ID: 1325577
Adjusted points to 250
0
 
LVL 2

Accepted Solution

by:
cramer091498 earned 250 total points
ID: 1325578
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
ID: 1325579
Thats excellent. Thanks; you're great!
0
 

Expert Comment

by:kibi
ID: 3798354
Thank you thank you thank you thank you thank you!
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
In this post we will learn different types of Android Layout and some basics of an Android App.
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.
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
Suggested Courses

623 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