SandBrowser, a basic Web Browsing Application!

Discussion in 'Programming General' started by Hey321, Sep 6, 2009.

SandBrowser, a basic Web Browsing Application!
  1. Unread #1 - Sep 6, 2009 at 12:50 AM
  2. Hey321
    Joined:
    Jul 30, 2007
    Posts:
    503
    Referrals:
    0
    Sythe Gold:
    0

    Hey321 Forum Addict

    SandBrowser, a basic Web Browsing Application!

    I did NOT write the html parsing, it was all included with my download of MVB2008 EE.

    This is for my learning purposes only. It's not really meant to be a functional browser, although you could if you wanted to. Please do not post something like this:

    "Oh, that sucks, so easy, could do it in five minutes"

    That's not the point of this - I'm trying to learn >.<. Had a couple of those at RSBot.

    Features:

    Forward and Back.
    Home page.
    Search engines work (pressing enter instead of search won't fuck it up).
    The url bar now displays the URL of the current page, instead of what you typed, and will change if you click a link.
    Custom buttons :D.
    Favorites!

    Bugs:

    Full screen youtube and the like don't accept the escape key.

    Source:

    Form One (the actual browser):

    Code:
    Public Class Form1
        Dim Homepage As Uri
        Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
            My.Settings.F2 = False
            My.Settings.F3 = False
        End Sub
        Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            Homepage = My.Settings.Homepage
            My.Settings.F2 = False
            My.Settings.F3 = False
            If Not Homepage = Nothing Then
                WebBrowser1.Navigate(Homepage)
                If Not My.Settings.HPURL = Nothing Then
                    TextBox1.Text = My.Settings.HPURL.ToString
                End If
            Else
                WebBrowser1.Navigate("www.google.com")
                TextBox1.Text = "www.google.com".ToString
            End If
            Me.Text = "SandBrowser - " & WebBrowser1.DocumentTitle
            TextBox1.AcceptsReturn = True
            If Not (My.Settings.URL.Count = Nothing) Then
                For i = 1 To (My.Settings.URL.Count - 1)
                    tlsFaves.DropDownItems.Add(My.Settings.URL.Item(i), Nothing, AddressOf Clicked)
                Next
            End If
        End Sub
    
        Private Sub WebBrowser1_DocumentCompleted(ByVal sender As System.Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted
            Me.Text = "SandBrowser - " & WebBrowser1.DocumentTitle
            TextBox1.Text = WebBrowser1.Url.ToString
        End Sub
    
        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            WebBrowser1.Navigate(TextBox1.Text)
        End Sub
        Private Sub Back_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Back.Click
            If WebBrowser1.CanGoBack Then
                WebBrowser1.GoBack()
            End If
        End Sub
        Private Sub Forward_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Back.Click
            If WebBrowser1.CanGoForward Then
                WebBrowser1.GoForward()
            End If
        End Sub
    
        Private Sub GoToYourHomepageToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles GoToYourHomepageToolStripMenuItem.Click
            If Not My.Settings.Homepage = Nothing Then
                WebBrowser1.Navigate(My.Settings.Homepage)
            Else
                WebBrowser1.GoHome()
            End If
        End Sub
    
        Private Sub UseCurrentPageToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles UseCurrentPageToolStripMenuItem.Click
            Homepage = WebBrowser1.Url
            My.Settings.Homepage = Homepage
            My.Settings.HPURL = WebBrowser1.Url
        End Sub
    
        Private Sub Home_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Home.Click
            GoToYourHomepageToolStripMenuItem.PerformClick()
        End Sub
    
        Private Sub Forward_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Forward.Click
            If WebBrowser1.CanGoForward Then
                WebBrowser1.GoForward()
            End If
        End Sub
    
        Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
            If Not TextBox1.Text = "" Then
                If e.KeyChar = Chr(13) Then
                    Button1.PerformClick()
                End If
            End If
        End Sub
    
        Private Sub UseACustomPageToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles UseACustomPageToolStripMenuItem.Click
            Dim SecondForm As New Form2
            If My.Settings.F2 Then
                SecondForm.Focus()
            Else
                SecondForm.Show()
                My.Settings.F2 = True
            End If
        End Sub
    
        Private Sub ViewCreditsToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ViewCreditsToolStripMenuItem.Click
            Dim ThirdForm As New Credits
            If My.Settings.F3 Then
                ThirdForm.Focus()
            Else
                ThirdForm.Show()
                My.Settings.F3 = True
            End If
        End Sub
    
    
        Sub Clicked(ByVal site As System.Object, ByVal e As System.EventArgs)
            WebBrowser1.Navigate(site.ToString)
            TextBox1.Text = site.ToString
        End Sub
    
        Private Sub BookmarkThisPageToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BookmarkThisPageToolStripMenuItem.Click
            tlsFaves.DropDownItems.Add(WebBrowser1.Url.ToString, Nothing, AddressOf Clicked)
            My.Settings.URL.Add(WebBrowser1.Url.ToString)
        End Sub
    End Class
    
    Form two (Custom home page set up):

    Code:
    Public Class Form2
        Private Sub F2ChangeHP_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles F2ChangeHP.Click
            If InStr(HPURL.Text, "http://") = 0 Then
                If InStr(HPURL.Text, "www.") = 0 Then
                    HPURL.Text = "http://www." & HPURL.Text
                Else
                    HPURL.Text = "http://" & HPURL.Text
                End If
            End If
            Dim HP As New Uri(HPURL.Text)
                If HPURL.Text <> "" Then
                    My.Settings.Homepage = HP
                    My.Settings.HPURL = HP
                    HPURL.Text = ""
                    Me.Hide()
                End If
        End Sub
    End Class
    Form three (credits):

    Code:
    Public Class Form3
    
        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            Me.Hide()
        End Sub
    End Class
    Post any opinions, ideas, help, whatever you think I could do to improve it. Just starting to learn Visual Basic, so yea :p.

    Download link, file is to big to attach:

    http://www.megaupload.com/?d=0P0YNUCF

    ~Sandstorm
     
  3. Unread #2 - Sep 6, 2009 at 9:23 AM
  4. kayosman
    Joined:
    Jun 8, 2008
    Posts:
    1,777
    Referrals:
    2
    Sythe Gold:
    0

    kayosman Guru
    Banned

    SandBrowser, a basic Web Browsing Application!

    Can you post some pictures? I want to see your designing :p
     
  5. Unread #3 - Sep 6, 2009 at 11:36 AM
  6. Hey321
    Joined:
    Jul 30, 2007
    Posts:
    503
    Referrals:
    0
    Sythe Gold:
    0

    Hey321 Forum Addict

    SandBrowser, a basic Web Browsing Application!

    You could always just download it, but alright...

    ~Sandstorm
     
  7. Unread #4 - Sep 6, 2009 at 4:35 PM
  8. Hey321
    Joined:
    Jul 30, 2007
    Posts:
    503
    Referrals:
    0
    Sythe Gold:
    0

    Hey321 Forum Addict

    SandBrowser, a basic Web Browsing Application!

    Added custom buttons and a background. Don't feel like screwing with pictures again, if someone would scan it, you guys'll know it's safe to download and look at it on your own?

    ~Sandstorm
     
  9. Unread #5 - Sep 7, 2009 at 2:27 AM
  10. Hey321
    Joined:
    Jul 30, 2007
    Posts:
    503
    Referrals:
    0
    Sythe Gold:
    0

    Hey321 Forum Addict

    SandBrowser, a basic Web Browsing Application!

    After four or five hours of pondering, testing, fixing, testing some more, and tweaking bugs, I introduce to you:

    Favorites! As yet they can't be removed, but this is being worked on.

    ~Sandstorm
     
  11. Unread #6 - Sep 7, 2009 at 2:31 AM
  12. Swan
    Joined:
    Jan 23, 2007
    Posts:
    4,957
    Referrals:
    0
    Sythe Gold:
    0
    Sythe's 10th Anniversary Member of the Month Winner

    Swan When They Cry...
    Retired Global Moderator

    SandBrowser, a basic Web Browsing Application!

    Err... All favourites are is a list. Hours, you say?
     
  13. Unread #7 - Sep 7, 2009 at 3:12 AM
  14. Hey321
    Joined:
    Jul 30, 2007
    Posts:
    503
    Referrals:
    0
    Sythe Gold:
    0

    Hey321 Forum Addict

    SandBrowser, a basic Web Browsing Application!

    Navigating to them on clicking them, as well as saving and loading them was hard. This is essentially my first visual basic project, I'm learning everything as I go.

    ~Sandstorm
     
  15. Unread #8 - Sep 7, 2009 at 5:33 PM
  16. Blupig
    Joined:
    Nov 23, 2006
    Posts:
    7,145
    Referrals:
    16
    Sythe Gold:
    1,609
    Discord Unique ID:
    178533992981594112
    Valentine's Singing Competition Winner Member of the Month Winner MushyMuncher Gohan has AIDS Extreme Homosex World War 3 I'm LAAAAAAAME
    Off Topic Participant

    Blupig BEEF TOILET
    $5 USD Donor

    SandBrowser, a basic Web Browsing Application!

    Well, you could store favorites as an array in either the My namespace settings or by saving them to a file/registry. Also, for the navigation part, just make 2 lists, one that is invisible (or simply another array) which stores the URLs, then another which stores the Favorite names. Then, all you need to do is deal with indexes of the array and the list so that the URL corresponds to the selected title in the favorites list, then once it's clicked, navigate to the selected item in the URL array. Hope that helped :D
     
  17. Unread #9 - Sep 7, 2009 at 5:46 PM
  18. Hey321
    Joined:
    Jul 30, 2007
    Posts:
    503
    Referrals:
    0
    Sythe Gold:
    0

    Hey321 Forum Addict

    SandBrowser, a basic Web Browsing Application!

    They already work, just need to add one last thing to it.

    During runtime I create a dropdown list button, and a sub button to that. If the sub button is clicked, I need to be able to know what the dropdown list button is. Any ideas?

    ~Sandstorm
     
< My first program | I need to parse HTML for emails, but its not working right >

Users viewing this thread
1 guest


 
 
Adblock breaks this site