Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

events in an embedded webbrowser control

Posted on 1998-12-01
7
Medium Priority
?
407 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
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!

 

Author Comment

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

Accepted Solution

by:
cramer091498 earned 1000 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

Learn how to optimize MySQL for your business need

With the increasing importance of apps & networks in both business & personal interconnections, perfor. has become one of the key metrics of successful communication. This ebook is a hands-on business-case-driven guide to understanding MySQL query parameter tuning & database perf

Question has a verified solution.

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

Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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.
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…

722 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