Post: VB.NET: Advanced Web Browser
05-15-2012, 11:14 PM #1
Pauly
Banned
(adsbygoogle = window.adsbygoogle || []).push({});
For this tutorial I will be teaching you how to make your very own web browser. With Tabs, Homepage, and Website Properties, as well as all the common functions (Back, Refresh, etc).
First Things First, Open up Visual Studio 2011, or 2010 this can be done on either version. Then Create a new project and call it Web Browser. Now we will start off with the design aspect of the browser first, your going to need a Tool strip, a Status strip, a tab control, and a timer.

Now your going to add a few thing to the Tool strip, 1 Drop Down Button, 6 Buttons, and 1 Combo Box. Then delete each individual tab so it looks like this. You must login or register to view this content.
Then Rename the Drop Down Button to File and add 3 Sub Menus to it called Add Tab, Close Tab, Website Properties in that order. Then rename the 6 buttons to Back, Forward, Refresh, Stop, Home, and Go In that order. So It should look like this. You must login or register to view this content.


Part 2: The Actual Code
I Will just paste the code in a spoiler for you guys to copy and paste make it easier for you. :p
Now as long as you followed the tutorial exactly as I wrote it you can just delete all the code in your project and paste this in.
    
Public Class Form1
Dim int As Integer = 0

Private Sub Loading(ByVal sender As Object, ByVal e As Windows.Forms.WebBrowserProgressChangedEventArgs)

End Sub

Private Sub Done(ByVal sender As Object, ByVal e As Windows.Forms.WebBrowserDocumentCompletedEventArgs)
TabControl1.SelectedTab.Text = CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).DocumentTitle
ToolStripComboBox1.Text = CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Url.ToString
End Sub

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim Browser As New WebBrowser
TabControl1.TabPages.Add("New Page")
Browser.Name = "Web Browser"
Browser.Dock = DockStyle.Fill
TabControl1.SelectedTab.Controls.Add(Browser)
AddHandler Browser.ProgressChanged, AddressOf Loading
AddHandler Browser.DocumentCompleted, AddressOf Done
int = int + 1
CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).GoHome()
End Sub

Private Sub AddTabToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AddTabToolStripMenuItem.Click
Dim Browser As New WebBrowser
TabControl1.TabPages.Add("New Page")
TabControl1.SelectTab(int)
Browser.Name = "Web Browser"
Browser.Dock = DockStyle.Fill
TabControl1.SelectedTab.Controls.Add(Browser)
AddHandler Browser.ProgressChanged, AddressOf Loading
AddHandler Browser.DocumentCompleted, AddressOf Done
int = int + 1
CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).GoHome()
End Sub

Private Sub RemoveTabToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CloseTabToolStripMenuItem.Click
If Not TabControl1.TabPages.Count = 1 Then
TabControl1.TabPages.RemoveAt(TabControl1.SelectedIndex)
TabControl1.SelectTab(TabControl1.TabPages.Count - 1)
int = int - 1
End If
End Sub

Private Sub WebsitePropertiesToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles WebsitePropertiesToolStripMenuItem.Click
CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).ShowPropertiesDialog()
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton1.Click
CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).GoBack()
End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton2.Click
CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).GoForward()
End Sub

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton3.Click
CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Refresh()
End Sub

Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton4.Click
CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Stop()
End Sub

Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton5.Click
CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).GoHome()
End Sub

Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton6.Click
CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Navigate(ToolStripComboBox1.Text)
End Sub

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick

End Sub
End Class

And here is the end result! =D
You must login or register to view this content.

The following 6 users say thank you to Pauly for this useful post:

Branhdon, IzBoogz, Lovol, Ninja, Pichu
05-15-2012, 11:19 PM #2
It looks pretty nice bro, I must say :p
05-15-2012, 11:27 PM #3
Pauly
Banned
Originally posted by Ninja View Post
It looks pretty nice bro, I must say :p

Thanks man, took me a while to write this up. Happy
05-15-2012, 11:51 PM #4
Pichu
RIP PICHU.
Good tutorial yet this is no different than running Internet Explorer.
05-16-2012, 01:57 AM #5
Epic?
Awe-Inspiring
Originally posted by Sublimity View Post
Good tutorial yet this is no different than running Internet Explorer.


I'd say it's much worse than running Internet Explorer, due to its inferior design and interface.
Last edited by Epic? ; 05-16-2012 at 06:35 PM.
05-16-2012, 04:31 AM #6
Pichu
RIP PICHU.
Originally posted by Epic
I'd say it's much worse than running Internet Explorer, due to it's inferior design and interface.


Can we just say that both suck and that neither should be used unless you are installing something better...
05-16-2012, 05:33 AM #7
Pauly
Banned
I love how you guys are actually criticizing this, it's not supposed to be like chrome it's just a simple browser in VB. :dumb:

The following user thanked Pauly for this useful post:

Pichu
05-16-2012, 05:51 AM #8
Pichu
RIP PICHU.
Originally posted by .Pauly. View Post
I love how you guys are actually criticizing this, it's not supposed to be like chrome it's just a simple browser in VB. :dumb:


Aha, we know. :P
05-16-2012, 06:10 AM #9
Branhdon
Child Rapist
Originally posted by .Pauly. View Post
For this tutorial I will be teaching you how to make your very own web browser. With Tabs, Homepage, and Website Properties, as well as all the common functions (Back, Refresh, etc).
First Things First, Open up Visual Studio 2011, or 2010 this can be done on either version. Then Create a new project and call it Web Browser. Now we will start off with the design aspect of the browser first, your going to need a Tool strip, a Status strip, a tab control, and a timer.

Now your going to add a few thing to the Tool strip, 1 Drop Down Button, 6 Buttons, and 1 Combo Box. Then delete each individual tab so it looks like this. You must login or register to view this content.
Then Rename the Drop Down Button to File and add 3 Sub Menus to it called Add Tab, Close Tab, Website Properties in that order. Then rename the 6 buttons to Back, Forward, Refresh, Stop, Home, and Go In that order. So It should look like this. You must login or register to view this content.


Part 2: The Actual Code
I Will just paste the code in a spoiler for you guys to copy and paste make it easier for you. :p
Now as long as you followed the tutorial exactly as I wrote it you can just delete all the code in your project and paste this in.
    
Public Class Form1
Dim int As Integer = 0

Private Sub Loading(ByVal sender As Object, ByVal e As Windows.Forms.WebBrowserProgressChangedEventArgs)

End Sub

Private Sub Done(ByVal sender As Object, ByVal e As Windows.Forms.WebBrowserDocumentCompletedEventArgs)
TabControl1.SelectedTab.Text = CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).DocumentTitle
ToolStripComboBox1.Text = CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Url.ToString
End Sub

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim Browser As New WebBrowser
TabControl1.TabPages.Add("New Page")
Browser.Name = "Web Browser"
Browser.Dock = DockStyle.Fill
TabControl1.SelectedTab.Controls.Add(Browser)
AddHandler Browser.ProgressChanged, AddressOf Loading
AddHandler Browser.DocumentCompleted, AddressOf Done
int = int + 1
CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).GoHome()
End Sub

Private Sub AddTabToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AddTabToolStripMenuItem.Click
Dim Browser As New WebBrowser
TabControl1.TabPages.Add("New Page")
TabControl1.SelectTab(int)
Browser.Name = "Web Browser"
Browser.Dock = DockStyle.Fill
TabControl1.SelectedTab.Controls.Add(Browser)
AddHandler Browser.ProgressChanged, AddressOf Loading
AddHandler Browser.DocumentCompleted, AddressOf Done
int = int + 1
CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).GoHome()
End Sub

Private Sub RemoveTabToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CloseTabToolStripMenuItem.Click
If Not TabControl1.TabPages.Count = 1 Then
TabControl1.TabPages.RemoveAt(TabControl1.SelectedIndex)
TabControl1.SelectTab(TabControl1.TabPages.Count - 1)
int = int - 1
End If
End Sub

Private Sub WebsitePropertiesToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles WebsitePropertiesToolStripMenuItem.Click
CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).ShowPropertiesDialog()
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton1.Click
CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).GoBack()
End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton2.Click
CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).GoForward()
End Sub

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton3.Click
CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Refresh()
End Sub

Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton4.Click
CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Stop()
End Sub

Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton5.Click
CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).GoHome()
End Sub

Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton6.Click
CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Navigate(ToolStripComboBox1.Text)
End Sub

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick

End Sub
End Class

And here is the end result! =D
You must login or register to view this content.



HAHAHAHAH finally got your web browser !! good job HEHEHEHEHE
05-16-2012, 05:51 PM #10
fill0botto95
You talkin to me?
Originally posted by .Pauly. View Post
I Will just paste the code in a spoiler for you guys to copy and paste make it easier for you.


Sorry, but this concept is totally wrong for me...

The following user thanked fill0botto95 for this useful post:

Epic?

Copyright © 2024, NextGenUpdate.
All Rights Reserved.

Gray NextGenUpdate Logo