PDA

View Full Version : SandBrowser, a basic Web Browsing Application!



Sandstorm
09-06-2009, 01:04 AM
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):


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.WebBrowserDocumentCompletedEv entArgs) 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.ToStrin g, Nothing, AddressOf Clicked)
My.Settings.URL.Add(WebBrowser1.Url.ToString)
End Sub
End Class


Form two (Custom home page set up):


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):


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

ShowerThoughts
09-06-2009, 01:31 AM
Simple, but good for vb, I can't even give it a look. :p

Sandstorm
09-06-2009, 02:00 AM
Yea, I'm hoping to add in favorites, home page, and the like, but I have to figure out saving and loading from files first :P.

~Sandstorm

ShowerThoughts
09-06-2009, 02:15 AM
Use XML or Ini file's they are easy enough for that kind of job.

Neehosoft
09-06-2009, 02:19 AM
Yea, I'm hoping to add in favorites, home page, and the like, but I have to figure out saving and loading from files first :P.

~Sandstorm
I could help with that, was version of VB are you using?

Sandstorm
09-06-2009, 02:30 AM
Microsoft Visual Basic 2008 EE. First one I found xD.

~Sandstorm

Neehosoft
09-06-2009, 02:41 AM
Microsoft Visual Basic 2008 EE. First one I found xD.

~Sandstorm

What types of file(s) do you wish to load?

ShowerThoughts
09-06-2009, 02:48 AM
What types of file(s) do you wish to load?


Yea, I'm hoping to add in favorites, home page, and the like, but I have to figure out saving and loading from files first :P.

~Sandstorm

Figure out what one is the best :D.

Neehosoft
09-06-2009, 02:52 AM
Figure out what one is the best :D.

ooh lol. Well then you should probably store it all in a file under a user folder with a some xml files that store the variables "homepage" and favorites in a nice list. When i used to have a vb web browser i even made a customized themeing option that loaded from the xml

Sandstorm
09-06-2009, 02:58 AM
I was thinking of just doing this (scar example):


Procedure Savehome;
Begin
Writeini(path, 'home', 'page', URL);
End;

Procedure Loadhome;
Begin
Homepage := Readini(path, 'home', 'page');
end;

Sort of like that. Not sure how I'd do it in VB though (the saving and loading, variable assignment is a snap).

And do the same thing for the favorites - teach me to save and load files and I can do the rest fine, if rather messily xD.

~Sandstorm

Nadeem
09-06-2009, 03:52 AM
In VB you can use the My.Settings feature and have the values written into the assembly form inside the exe. Checkout: http://msdn.microsoft.com/en-us/library/ms379611%28VS.80%29.aspx



~NS

Sandstorm
09-06-2009, 04:52 AM
Thanks, but that doesn't help much. I've found like five tutorials on it, but they all assume knowledge of the coding, and so it looks like a big jumble to me :(.

~Sandstorm

ShowerThoughts
09-06-2009, 04:58 AM
Thanks, but that doesn't help much. I've found like five tutorials on it, but they all assume knowledge of the coding, and so it looks like a big jumble to me :(.

~Sandstorm

Don't give up! :)
I just don't code Visual Basic :(.

Sandstorm
09-06-2009, 05:07 AM
Yea, I'm still looking around, but the future looks bleak at this point in time :(.

~Sandstorm

TViYH
09-06-2009, 05:34 AM
Button1_Click(Me, EventArgs.Empty)

Do this instead: Button1.PerformClick

Also, you don't need that. Just set the Form's AcceptButton to Button1.

Also, give the controls names that you can remember, such as btnGo, txtURL, etc.

Rick
09-06-2009, 05:51 AM
Yea, I'm still looking around, but the future looks bleak at this point in time :(.

~Sandstorm

Don't give up!
The My.Settings feature is actually pretty easy to use once you understand it. I'll make an easy to follow tutorial for you.

Sandstorm
09-06-2009, 06:46 AM
@TViYH - Cool, that's what I originally tried to do, but couldn't find it :P.

@R!ch!e - Wow, thanks! And yea, most things are easy - once you understand them.

~Sandstorm

Rick
09-06-2009, 07:15 AM
Sandstorm, hopefully this will give you a basic idea on how to use My.Settings :)

http://www.villavu.com/forum/showthread.php?p=627542#post627542

Sandstorm
09-06-2009, 07:47 AM
Perfect! So much easier to understand. Home page is working now. Just gotta figure out the favorites, and I'll release this next one.

~Sandstorm

Sandstorm
09-06-2009, 12:29 PM
Home page now works - try to crash it through the use of the custom home page please! I need to know if anything has to be added to make it crash-proof.

Fixed that damn forward button :P.

Fixed search engines such as google and youtube not working. You'd press enter and it would just refresh the page.

Fixed the url area - it'll now change the url based on the page.

Tell me what you think, and any bugs!

~Sandstorm

cycrosism
09-06-2009, 02:03 PM
Visual Basic? No thnx no one uses that

Neehosoft
09-06-2009, 02:10 PM
Visual Basic? No thnx no one uses that

dont hate vb just becuase your ubuntu?

Rick
09-06-2009, 11:08 PM
Visual Basic? No thnx no one uses that

Why bother posting or even looking in the VB section if "no one" uses it?

Sandstorm, it looks much better now. Just a quick thing I noticed, when you use the home page button you should make it update the Address Bar, as it remains as the previously visited URL.

Sandstorm
09-06-2009, 11:29 PM
Why bother posting or even looking in the VB section if "no one" uses it?

Sandstorm, it looks much better now. Just a quick thing I noticed, when you use the home page button you should make it update the Address Bar, as it remains as the previously visited URL.

I put that in the page load trigger?

Added custom buttons and changed the background.

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

cycrosism
09-09-2009, 12:30 PM
No I am just saying in the programming industry no one uses visual basic. This has nothing to do with the fact I use ubuntu.

Sandstorm
09-09-2009, 01:21 PM
No I am just saying in the programming industry no one uses visual basic. This has nothing to do with the fact I use ubuntu.

*Insert point here*

~Sandstorm

TViYH
09-10-2009, 05:43 AM
No I am just saying in the programming industry no one uses visual basic. This has nothing to do with the fact I use ubuntu.

Actually, VERY many programmers in the programming industry use VB.NET.

By the way, since when are YOU in the programming industry to know that "no one uses it"?

Freddy1990
09-10-2009, 07:12 PM
You should try to build your own browser control and you'll have my wow :) Use a socket to get the page, process the html code and display it (hf writing a javascript engine, lol)

Sandstorm
09-11-2009, 03:26 AM
I'll look into it, I guess o.o.

~Sandstorm

Freddy1990
09-11-2009, 05:10 AM
I'll look into it, I guess o.o.

~Sandstorm

Heh, I was kidding, it'd take months to develop a stable browser, let alone a good one...

Sandstorm
09-11-2009, 06:05 AM
Heh, I was kidding, it'd take months to develop a stable browser, let alone a good one...

I have months o.o.

~Sandstorm

Bobarkinator
09-11-2009, 11:09 AM
Homemade javascript engine = win

Freddy1990
09-19-2009, 11:25 PM
Homemade javascript engine = win

Homemade javascript engine = epic fail
Gl beating speeds of Firefox' engine and such...

Bionicle
09-19-2009, 11:27 PM
Homemade javascript engine = epic fail
Gl beating speeds of Firefox' engine and such...

You want speed? try google crome. Its uber fast, but fails with java. so runescape is out of the question xD

Bobarkinator
09-20-2009, 07:54 AM
Homemade javascript engine = epic fail
Gl beating speeds of Firefox' engine and such...

Lol, I wouldn't try to compete with speeds. Just feel accomplished for writing your own JS engine.

rogeruk
09-20-2009, 06:58 PM
Google Chrome sux lol.

Looking good!

fronty
09-27-2009, 04:35 PM
Actually, VERY many programmers in the programming industry use VB.NET.

By the way, since when are YOU in the programming industry to know that "no one uses it"?

Visual Basic and Visual Basic.NET are very different things. Many companies use VB.NET, but many are still tied to VB6 because rewriting big commercial software is so expensive.