Webbrowser Advice and simple tut

Heres your chance to share your own tutorials with the community. Just post them on here. If your lucky they may even be posted on the main site.
2 posts Page 1 of 1
Contributors
User avatar
muttley1968
Hardcore Programmer
Hardcore Programmer
Posts: 622
Joined: Thu Jun 17, 2010 11:54 pm

Hello well I have made ARKs webbrowser today simple but I was also suppose to be teaching my mate basics soo I started with this now I decided to keep it as its quite nice but I need help with a faves system I want one that works on the same lines as the windows bar but want it to look really new and different but just gone blank for ideas soo here is my code and a picture thanks

Image
Oh yh you can set a background like in chrome and it rembers but the defult is a grey that is 60,60,60
Code: Select all
Public Class Browser
#Region "Random From shiz"
#Region "Form controlls"
    '=========================================================
    'Here are the resize controlls if you need any help in making
    'a controll resize with the form just ask me and i will show you.
    '=========================================================
#Region "Privates"
    Private WithEvents Resize_Form_BR As New Timer
    Private WithEvents Resize_Form_B As New Timer
    Private WithEvents Resize_Form_R As New Timer
    Private WithEvents Resize_From_L As New Timer
#End Region
#Region "Dim"
    Dim PrevWindowState As String
    Dim AppLoc, CurLoc As New Point(0, 0)
    Dim AppSize, CurPos As New Point(0, 0)
    Dim CursX As Integer = 0
    Dim CursY As Integer = 0
    Dim AppHeight As Integer = 0
    Dim AppWidth As Integer = 0
    Dim AppH As Integer = 0
    Dim AppW As Integer = 0

#End Region
#Region "Definitions"
    Private Sub Definitions()
        AppLoc = Location
        CurLoc = Cursor.Position
        CursX = Cursor.Position.X
        CursY = Cursor.Position.Y
        AppHeight = Me.Height
        AppWidth = Me.Width
        AppSize = Me.Size
        CurPos = Cursor.Position
    End Sub

#End Region
#Region "Resize The Form From The Bottom Right"

    Private Sub Resize_Form_BR_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Resize_Form_BR.Tick
        Me.Height = AppHeight - CursY + Cursor.Position.Y
        Me.Width = AppWidth - CursX + Cursor.Position.X
    End Sub

    Private Sub Panel14_MouseEnter(ByVal sender As Object, ByVal e As System.EventArgs) Handles Panel14.MouseEnter
        Me.Cursor = Cursors.SizeNWSE
    End Sub

    Private Sub Panel14_MouseLeave(ByVal sender As Object, ByVal e As System.EventArgs) Handles Panel14.MouseLeave
        Me.Cursor = Cursors.Default
    End Sub

    Private Sub Panel14_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Panel14.MouseDown
        Resize_Form_BR.Enabled = True
        Resize_Form_BR.Start()
        Definitions()
    End Sub

    Private Sub Panel14_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Panel14.MouseUp
        Resize_Form_BR.Stop()
        Definitions()
    End Sub

#End Region
#Region "Resize The Form From The left"

    Private Sub Resize_Form_L_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Resize_From_L.Tick
        Me.Width = AppWidth - CursX + Cursor.Position.X
    End Sub

    Private Sub Panel2_MouseEnter(ByVal sender As Object, ByVal e As System.EventArgs) Handles Panel2.MouseEnter
        Me.Cursor = Cursors.SizeWE
    End Sub

    Private Sub Panel2_MouseLeave(ByVal sender As Object, ByVal e As System.EventArgs) Handles Panel2.MouseLeave
        Me.Cursor = Cursors.Default
    End Sub

    Private Sub Panel2_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Panel2.MouseDown
        Resize_From_L.Enabled = True
        Resize_From_L.Start()
        Definitions()
    End Sub

    Private Sub Panel2_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Panel2.MouseUp
        Resize_From_L.Stop()
        Definitions()
    End Sub

#End Region
#Region "Resize The Form From The Right Side"


    Private Sub Resize_Form_R_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Resize_Form_R.Tick
        Me.Width = AppWidth - CursX + Cursor.Position.X
    End Sub

    Private Sub Panel3_MouseEnter(ByVal sender As Object, ByVal e As System.EventArgs) Handles Panel3.MouseEnter
        Me.Cursor = Cursors.SizeWE
    End Sub

    Private Sub Panel3_MouseLeave(ByVal sender As Object, ByVal e As System.EventArgs) Handles Panel3.MouseLeave
        Me.Cursor = Cursors.Default
    End Sub

    Private Sub Panel3_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Panel3.MouseUp
        Resize_Form_R.Stop()
        Definitions()
    End Sub

    Private Sub Panel3_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Panel3.MouseDown
        Resize_Form_R.Enabled = True
        Resize_Form_R.Start()
        Definitions()
    End Sub

#End Region
#Region "Resize The Form From The Bottom"

    Private Sub Resize_Form_B_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Resize_Form_B.Tick
        Me.Height = AppHeight - CursY + Cursor.Position.Y
    End Sub

    Private Sub Panel4_MouseEnter(ByVal sender As Object, ByVal e As System.EventArgs) Handles Panel4.MouseEnter
        Me.Cursor = Cursors.SizeNS
    End Sub

    Private Sub Panel4_MouseLeave(ByVal sender As Object, ByVal e As System.EventArgs) Handles Panel4.MouseLeave
        Me.Cursor = Cursors.Default
    End Sub

    Private Sub Panel4_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Panel4.MouseDown
        Resize_Form_B.Enabled = True
        Resize_Form_B.Start()
        Definitions()
    End Sub

    Private Sub Panel4_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Panel4.MouseUp
        Resize_Form_B.Stop()
        Definitions()
    End Sub

#End Region
#Region "move"
    Dim NewPoint As New System.Drawing.Point()
    Dim X, Y As Integer
    Private Sub Child_Top_Panel_MouseDown1(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Panel1.MouseDown
        X = Control.MousePosition.X - Me.Location.X
        Y = Control.MousePosition.Y - Me.Location.Y
    End Sub

    Private Sub Child_Top_Panel_MouseMove1(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Panel1.MouseMove
        If e.Button = MouseButtons.Left Then
            NewPoint = Control.MousePosition
            NewPoint.X -= (X)
            NewPoint.Y -= (Y)
            Me.Location = NewPoint
        End If
    End Sub
#End Region
#End Region
    Private Sub PictureBox2_Click(sender As Object, e As EventArgs) Handles PictureBox2.Click
        Me.Close()
    End Sub

    Private Sub PictureBox3_Click(sender As Object, e As EventArgs) Handles PictureBox3.Click
        If Me.WindowState = FormWindowState.Maximized Then
            Me.WindowState = FormWindowState.Normal
        Else
            Me.WindowState = FormWindowState.Maximized
        End If
    End Sub
    Private Sub PictureBox1_Click(sender As Object, e As EventArgs) Handles PictureBox1.Click
        Me.WindowState = FormWindowState.Minimized
    End Sub
#End Region
    Dim int As Integer = 0
    Private Sub Loading(ByVal sender As Object, ByVal e As Windows.Forms.WebBrowserProgressChangedEventArgs)
        ToolStripProgressBar1.Maximum = e.MaximumProgress
        ToolStripProgressBar1.Value = e.CurrentProgress
    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
        ComboBox1.Text = CType(Tabcontrol1.SelectedTab.Controls.Item(0), WebBrowser).Url.ToString
    End Sub
    Private Sub Browser_Load(sender As Object, e As EventArgs) Handles Me.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()
        If My.Settings.backgroundweb = "" Then
            'do nothing
        Else
            Me.BackgroundImage = Image.FromFile(My.Settings.backgroundweb)
        End If
    End Sub
    Private Sub AddTabToolStripMenuItem_Click(sender As Object, e As 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(sender As Object, e As EventArgs) Handles RemoveTabToolStripMenuItem.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 WebstiePropertiesToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles WebstiePropertiesToolStripMenuItem.Click
        CType(Tabcontrol1.SelectedTab.Controls.Item(0), WebBrowser).ShowPropertiesDialog()
    End Sub

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        CType(Tabcontrol1.SelectedTab.Controls.Item(0), WebBrowser).GoBack()
    End Sub

    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
        CType(Tabcontrol1.SelectedTab.Controls.Item(0), WebBrowser).GoForward()
    End Sub

    Private Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.Click
        CType(Tabcontrol1.SelectedTab.Controls.Item(0), WebBrowser).Refresh()
    End Sub

    Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
        CType(Tabcontrol1.SelectedTab.Controls.Item(0), WebBrowser).Stop()
    End Sub

    Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
        CType(Tabcontrol1.SelectedTab.Controls.Item(0), WebBrowser).GoHome()
    End Sub

    Private Sub Button6_Click(sender As Object, e As EventArgs) Handles Button6.Click
        CType(Tabcontrol1.SelectedTab.Controls.Item(0), WebBrowser).Navigate(ComboBox1.Text)
    End Sub

    Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
        ToolStripStatusLabel1.Text = CType(Tabcontrol1.SelectedTab.Controls.Item(0), WebBrowser).StatusText
    End Sub

    Private Sub ToolStripMenuItem5_Click(sender As Object, e As EventArgs) Handles ToolStripMenuItem5.Click
        Dim OpenFileDialog1 As New OpenFileDialog
        With OpenFileDialog1
            .CheckFileExists = True
            .ShowReadOnly = False
            .Filter = "All Files|*.*|Bitmap Files (*)|*.bmp;*.gif;*.jpg"
            .FilterIndex = 2
            If .ShowDialog = DialogResult.OK Then
                Me.BackgroundImage = Image.FromFile(.FileName)
                Me.Refresh()
                My.Settings.backgroundweb = (.FileName)
            End If
        End With
    End Sub

    Private Sub Button7_Click(sender As Object, e As EventArgs) Handles Button7.Click
        Faves.Items.Add(ComboBox1.Text)
    End Sub
    Private Sub combobox1_KeyPress(sender As Object, e As System.Windows.Forms.KeyPressEventArgs) Handles ComboBox1.KeyPress
        If e.KeyChar = Chr(13) Then
            CType(Tabcontrol1.SelectedTab.Controls.Item(0), WebBrowser).Navigate(ComboBox1.Text)
        End If
    End Sub

    Private Sub Button8_Click(sender As Object, e As EventArgs) Handles Button8.Click
        Faves.Items.Remove(Faves.SelectedItem)
    End Sub

    Private Sub Faves_SelectedIndexChanged(sender As Object, e As EventArgs) Handles Faves.SelectedIndexChanged
        CType(Tabcontrol1.SelectedTab.Controls.Item(0), WebBrowser).Navigate(Faves.SelectedItem)
    End Sub
End Class
User avatar
muttley1968
Hardcore Programmer
Hardcore Programmer
Posts: 622
Joined: Thu Jun 17, 2010 11:54 pm

Rather then start a new thread thought i would post on here that i have made ALOT of updates to this webbrowser to make it even more advance it is now almost as good as chrome i would say few kinks but working on them anyway does anyone know of a custom toolstrip control and also when this is compleated i will be releasing all the source on here :P ohh and can anyone point me to a good tut about Treeviews as i wish to implment one into my history system
2 posts Page 1 of 1
Return to “Tutorials”