5,692,513 members and growing! (15,932 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.
VBWindows, .NET, .NET 1.0, Win2K, WinXP, Win2003VS.NET2002, Visual Studio, Dev

Posted: 14 Jul 2003
Updated: 14 Jul 2003
Views: 80,636
Bookmarked: 9 times
Announcements
Loading...



Search    
Advanced Search
Sitemap
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



Location: United Kingdom United Kingdom

Other popular VB.NET articles:

Article Top
Sign Up to vote for this article
You must Sign In to use this message board.
FAQ FAQ Noise ToleranceSearch Search Messages 
 Layout  Per page   
 Msgs 1 to 13 of 13 (Total in Forum: 13) (Refresh)FirstPrevNext
GeneralHow can I record all http activity of shdocvwmemberSuber2:50 4 Mar '08  
Generalhow 2 work with combo box using axWebBrowser1 ?membervedmack23:52 7 Jan '06  
AnswerRe: how 2 work with combo box using axWebBrowser1 ?memberDatta Deshmukh21:33 23 Nov '08  
GeneralAxWebBrowser Proxy SetmemberUsman Syed19:22 14 Dec '05  
GeneralAutoLogin in ForumsmemberVitoto16:27 5 Oct '05  
GeneralAxWeb browsersussLalit Dubey2:54 26 Jun '05  
GeneralDebugging axWebbrowser control eventsmemberTysonM21:39 7 Feb '04  
GeneralHai it's working fine... How do i handle javascript errors?memberAjai Kumar Ramamoorthy2:46 20 Dec '03  
General[Q] web session lost..on pop-up window.memberjucy1:20 18 Sep '03  
GeneralRe: [Q] web session lost..on pop-up window.sussAnonymous19:32 19 Jun '04  
GeneralRe: [Q] web session lost..on pop-up window.memberlorenzo.gardoni22:38 7 May '07  
Generaljust the jobsussdave stewart6:10 16 Jul '03  
GeneralRe: just the jobmemberdynamic23: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-2008
Web17 | Advertise on the Code Project