Solved

events in an embedded webbrowser control

Posted on 1998-12-01
7
352 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
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
Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

 

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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Decoding 32 bit binary streams 6 42
Rewrite URL With Encoded Characters 6 78
isEverywhere  challenge 19 75
Fibonacci challenge 11 121
Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
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.

774 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