|
Public Class Form1
Dim stack As New Stack(Of String)
Dim lastUrl As String = ""
Dim confirmClosed As Boolean = False
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
LoadSettings()
ComboBox1.Text = My.Settings.strHomePage
If strHomeUrl <> "" Then
ComboBox1.Text = strHomeUrl.Replace("""", "")
End If
If ComboBox1.Text <> "" Then
Go(ComboBox1.Text)
End If
End Sub
#Region "Menu Action"
Private Sub VerticalLayoutToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles VerticalLayoutToolStripMenuItem.Click
V_Layout()
End Sub
Private Sub HorizontalLayoutToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles HorizontalLayoutToolStripMenuItem.Click
H_Layout()
End Sub
Private Sub QuitToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles QuitToolStripMenuItem.Click
Me.Close()
End Sub
#End Region
#Region "Click Events"
Private Sub btnGo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnGo.Click
Go(ComboBox1.Text)
End Sub
Private Sub picBack_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles picBack.Click
Back()
End Sub
Private Sub picRefresh_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles picRefresh.Click
WebBrowser1.Refresh()
End Sub
Private Sub picHome_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles picHome.Click
Go(txtHomePage.Text)
End Sub
Private Sub picFavorite_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles picFavorite.Click
Go(txtFavoritePage.Text)
End Sub
Private Sub btnSaveDefault_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSaveDefault.Click
SaveSettings()
End Sub
Private Sub btnClose_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClose.Click
confirmClosed = True
Me.Close()
End Sub
#End Region
Private Sub WebBrowser1_DocumentCompleted(ByVal sender As System.Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted
ComboBox1.Text = WebBrowser1.Url.ToString
End Sub
Private Sub Go(ByVal strUrl As String)
Try
If Not ComboBox1.Items.Contains(strUrl) Then
ComboBox1.Items.Add(strUrl)
End If
If lastUrl <> strUrl Then
lastUrl = strUrl
stack.Push(strUrl)
End If
If Not strUrl.ToUpper.StartsWith("HTTP://") Then
strUrl = "http://" & strUrl
End If
WebBrowser1.Url = New Uri(strUrl)
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Exclamation)
End Try
End Sub
Private Sub Back()
If stack.Count > 0 Then
lastUrl = stack.Pop
If stack.Count > 0 Then
lastUrl = stack.Pop
End If
ComboBox1.Text = lastUrl
Go(lastUrl)
End If
End Sub
Private Sub LoadSettings()
txtHomePage.Text = My.Settings.strHomePage
txtFavoritePage.Text = My.Settings.strFavoritePage
End Sub
Private Sub SaveSettings()
My.Settings.strHomePage = txtHomePage.Text
My.Settings.strFavoritePage = txtFavoritePage.Text
My.Settings.Save()
MsgBox("New Settings Saved")
End Sub
Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
Panel1.Visible = True
If confirmClosed = True Then
e.Cancel = False
Else
e.Cancel = True
End If
End Sub
End Class
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.