Click here to Skip to main content
6,291,124 members and growing! (15,762 online)
Email Password   helpLost your password?
Languages » VB.NET » HowTo     Intermediate

Extending the axWebbrowser control events.

By dynamic

How to extend the axWebbrowser's events in VB.NET.
VB.NET 1.0, Win2K, WinXP, Win2003, Dev
Posted:14 Jul 2003
Views:86,745
Bookmarked:13 times
Announcements
Loading...
 
Search    
Advanced Search
printPrint   Broken Article?Report       add Share
  Discuss Discuss   Recommend Article Email
11 votes for this article.
Popularity: 2.39 Rating: 2.29 out of 5
4 votes, 36.4%
1
1 vote, 9.1%
2
3 votes, 27.3%
3
1 vote, 9.1%
4
2 votes, 18.2%
5

Introduction

I have seen several messages on various VB.NET boards regarding problems with the axWebbrowser control (the BeforeNavigate2 event not working), so I decided to try to combat the issue and here is the result.

Using the code

Firstly, add a axWebbrowser control to a form, in this case called brweb. Then we need to add a SHDocVw.DWebBrowserEvents_Event below the "Windows generated code" area. This will be the new event handler for brWeb. Next, it's a simple test using a few lines of code to show how the BeforeNavigate event is handled.

Private WithEvents doc As SHDocVw.DWebBrowserEvents_Event 
     '/// doc will handle all the events for brweb now... 

     Private Sub Form1_Load(ByVal sender As System.Object, _ 
           ByVal e As System.EventArgs) Handles MyBase.Load 
         Dim b As Object = brWeb.Application 
         doc = DirectCast(b, SHDocVw.WebBrowser_V1) 
         '///set doc as the active handler for brweb's events. 

     End Sub 
  
     Private Sub Button1_Click(ByVal sender As System.Object, _ 
             ByVal e As System.EventArgs) Handles Button1.Click 
         brWeb.Navigate("http://google.com") '///lets navigate to a website. 

     End Sub 
  
     Private Sub doc_BeforeNavigate(ByVal URL As String, _ 
             ByVal Flags As Integer, ByVal TargetFrameName As String, _ 
             ByRef PostData As Object, ByVal Headers As String, _ 
             ByRef Cancel As Boolean) Handles doc.BeforeNavigate 
         MessageBox.Show(URL) '/// check that before navigate now works. 

     End Sub 
  
     Private Sub doc_StatusTextChange(ByVal _ 
             [Text] As String) Handles doc.StatusTextChange 
         Label1.Text = Text '///show the status text in a label. 

     End Sub 
  
     Private Sub doc_TitleChange(ByVal [Text] As String) _ 
                                       Handles doc.TitleChange 
         MyBase.Text = Text '/// set the form's caption to the current url 

     End Sub

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

dynamic


Member

Location: United Kingdom United Kingdom

Other popular VB.NET articles:

Article Top
You must Sign In to use this message board.
FAQ FAQ 
 
Noise Tolerance  Layout  Per page   
 Msgs 1 to 13 of 13 (Total in Forum: 13) (Refresh)FirstPrevNext
GeneralHow can I record all http activity of shdocvw PinmemberSuber2:50 4 Mar '08  
Generalhow 2 work with combo box using axWebBrowser1 ? Pinmembervedmack23:52 7 Jan '06  
AnswerRe: how 2 work with combo box using axWebBrowser1 ? PinmemberDatta Deshmukh21:33 23 Nov '08  
GeneralAxWebBrowser Proxy Set PinmemberUsman Syed19:22 14 Dec '05  
GeneralAutoLogin in Forums PinmemberVitoto16:27 5 Oct '05  
GeneralAxWeb browser PinsussLalit Dubey2:54 26 Jun '05  
GeneralDebugging axWebbrowser control events PinmemberTysonM21:39 7 Feb '04  
GeneralHai it's working fine... How do i handle javascript errors? PinmemberAjai Kumar Ramamoorthy2:46 20 Dec '03  
General[Q] web session lost..on pop-up window. Pinmemberjucy1:20 18 Sep '03  
GeneralRe: [Q] web session lost..on pop-up window. PinsussAnonymous19:32 19 Jun '04  
GeneralRe: [Q] web session lost..on pop-up window. Pinmemberlorenzo.gardoni22:38 7 May '07  
Generaljust the job Pinsussdave stewart6:10 16 Jul '03  
GeneralRe: just the job Pinmemberdynamic23:19 20 Jul '03  

General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

PermaLink | Privacy | Terms of Use
Last Updated: 14 Jul 2003
Editor: Smitha Vijayan
Copyright 2003 by dynamic
Everything else Copyright © CodeProject, 1999-2009
Web19 | Advertise on the Code Project