[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 750
  • Last Modified:

Help with WEb browser in MFC Application

Hello grp members,

 I am using web browser control in my mfc application. Now the problem is when i am navigate any page in it. if that page is failed to load. How can  i get it programmatically. means if i get the error like page cannot be displayed. How can I detect this message.

Can anybody help me out in this small problem?

Hoping for the solution...

Mukti.
0
pmukti
Asked:
pmukti
  • 5
  • 3
1 Solution
 
mrwad99Commented:
I have done a lot of work with the web browser control, and the way you handle this is by handling the message NavigateError.  See http://msdn.microsoft.com/workshop/browser/webbrowser/reference/ifaces/dwebbrowserevents2/navigateerror.asp for exact details.

HTH
0
 
pmuktiAuthor Commented:
Hello,

Thank you very much for your response.
the problem is that
I can see the event available in webbrowser control in its help file but when I add the control in program and see its event list. i can't be able to see this event.
Can you explain it with some step. I can see the beforeNaviage2, etc event in the event list.
How can I add this event in my program?

I had tried to manually add this event but not get success.
0
 
mrwad99Commented:
Once you have added the control, and created the wrapper class (by double clicking the control in the dialogue editor - VC++ will prompt you to add a wrapper class) you need to open the class which you want to handle this message (say your dialogue class that contains the control) in the classview (left hand side of MSVC++), right click and then select "Add windows message handler".  Then select to handle the web browser object in the list box that appears in the dialogue, under "Select object to handle", then the events for the browser will appear in the large list box on the left.
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!

 
pmuktiAuthor Commented:
Hello ,

Thank you very much for your step guideline. That is true how to add event of web browser control in dialog editor.what I want to tell you is, there is no "NaviageError" function in event list.
Do you think that the control I am using which is not supporting this event?  May be the version is different.
What is ur comment?

Mukti.
0
 
mrwad99Commented:
Hmm, that is strange.  I don't have VC++ with me currently, so I will look this up later.  Are you sure there is no event like this listed, not even something like "OnNavigateError" ?  The message name may also be ended with the name of the browser control you have added to the dialogue, eg if your control is Browser then the message handler could be

OnNavigateErrorBrowser

Either way I will get back to you about this.
0
 
mrwad99Commented:
Right then.  I created a basic dialogue application, then right clicked the dialogue in the resource editor, selected "Insert ActiveX control..." then selected Microsoft Web Browser.  VC++ gave the control the ID IDC_EXPLORER1 by default, which I left. You then need to create a wrapper class for the object, so right click the control, select classwizard, then member variables and select IDC_EXPLORER1 or whatever your control is called.  Then add a variable, accept the fact that you need to add wrapper classes, and the default file names for the classes, then give your browser a name something like m_wndBrowser.  

I then decided to handle the NavigateError message in the dialogue class that hosts the control, so I right click the class in the classview (here CGDlg), select IDC_EXPLORER1 as the control to handle, then select NavigateError, as shown at http://mrwad99.125mb.com/EG.jpg.  You can take it from there :)
0
 
pmuktiAuthor Commented:
Hello,

Thank you very much for your help. I had tried the same thing in some other system where I am getting NavigateError event even after doing the same process done in prev. system. so may be the problem is that the Webbrowser control version is different so that's why I am not able to see this.
Again Thank you very much for yr time and support.


Mukti.
0
 
mrwad99Commented:
>> I had tried the same thing in some other system

You would need to open up the WebBrowser activeX control and see what version you have on both systems to clarify that.  Glad to help anyway.
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!

  • 5
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now