Criaçao de Web Browser para quem iniciar Vb.2010 :)

kimuna

Membro
Vb2010

comandos toolbox

MenuStip
Toolstip
StatusStrip
Contextmenustrip


Public
ClassJanelaPrincipal
Dim frmAbrirLocal AsNewAbrirLocal
PrivateSub SobreToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SobreToolStripMenuItem.Click
AboutBox.ShowDialog()
EndSub
PrivateSub SairToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SairToolStripMenuItem.Click
Application.Exit()
EndSub
PrivateSub tstbUrl_KeyUp(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles tstbUrl.KeyUp
If e.KeyCode = Keys.Enter Then
Dim wb AsWebBrowser
wb = CType(Me.TabControl.SelectedTab.Controls.Item(0), WebBrowser)
wb.Navigate(
Me.tstbUrl.Text)
EndIf
EndSub
PrivateSub JanelaPrincipal_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) HandlesMyBase.Load
Call AbrirNovaAba()
EndSub
PrivateSub AbrirNovaAba()
' Declarar uma nova aba.
Dim NovaAba AsNewTabPage
' Declarar um novo controlo WebBrowser.
Dim NovaWeb AsNewWebBrowser
' WebBrowser vai preencher toda a área da aba.
NovaWeb.Dock = DockStyle.Fill
' Dar um título à aba.
NovaAba.Text = "Browser " & (TabControl.TabPages.Count + 1)
' Adicionar o controlo WebBrowser à Aba.
NovaAba.Controls.Add(NovaWeb)
' Adicionar a Aba ao TabControl.
Me.TabControl.TabPages.Add(NovaAba)
' Definir os eventos do controlo WebBrowser.
AddHandler NovaWeb.Navigating, AddressOf WebBrowser_Navigating
AddHandler NovaWeb.ProgressChanged,
AddressOf WebBrowser_ProgressChanged
AddHandler NovaWeb.DocumentCompleted,
AddressOf WebBrowser_DocumentCompleted
EndSub
PrivateSub WebBrowser_Navigating(
ByVal sender As System.Object,
ByVal e As System.Windows.Forms.WebBrowserNavigatingEventArgs)
Me.sslblPronto.Text = "A carregar: " & e.Url.Host.ToString
Me.sspbEstado.Value = Me.sspbEstado.Minimum
Me.sspbEstado.Visible = True
EndSub
PrivateSub WebBrowser_ProgressChanged(
ByVal sender As System.Object,
ByVal e As Windows.Forms.WebBrowserProgressChangedEventArgs)
If e.CurrentProgress < e.MaximumProgress Then
IfMe.sspbEstado.Value >= Me.sspbEstado.Maximum Then
Me.sspbEstado.Value = Me.sspbEstado.Minimum
Else
Me.sspbEstado.PerformStep()
EndIf
EndIf
EndSub
PrivateSub WebBrowser_DocumentCompleted(
ByVal sender As System.Object,
ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs)
Dim wb AsWebBrowser
wb = CType(Me.TabControl.SelectedTab.Controls.Item(0), WebBrowser)
Me.TabControl.SelectedTab.Text = wb.DocumentTitle
Me.sslblPronto.Text = "Pronto"
Me.sspbEstado.Visible = False
EndSub
PrivateSub NovaAbaToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NovaAbaToolStripMenuItem.Click, NovaAbaToolStripMenuItem1.Click
Call AbrirNovaAba()
EndSub
PrivateSub FecharAbaActivaToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FecharAbaActivaToolStripMenuItem.Click, FecharAbaActivaToolStripMenuItem1.Click
IfMe.TabControl.TabPages.Count > 1 Then
Me.TabControl.TabPages.Remove(Me.TabControl.SelectedTab)
EndIf
EndSub
PrivateSub AbrirLocalToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AbrirLocalToolStripMenuItem.Click
Dim res AsDialogResult
res = frmAbrirLocal.ShowDialog
If res = Windows.Forms.DialogResult.OK Then
Dim wb AsWebBrowser
wb = CType(Me.TabControl.SelectedTab.Controls.Item(0), WebBrowser)
wb.Navigate(frmAbrirLocal.txtUrl.Text)
EndIf
frmAbrirLocal.txtUrl.Text = ""
EndSub
PrivateSub RetrocederToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RetrocederToolStripMenuItem.Click
Dim wb AsWebBrowser
wb = CType(Me.TabControl.SelectedTab.Controls.Item(0), WebBrowser)
wb.GoBack()
EndSub
PrivateSub AvançarToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AvançarToolStripMenuItem.Click
Dim wb AsWebBrowser
wb = CType(Me.TabControl.SelectedTab.Controls.Item(0), WebBrowser)
wb.GoForward()
EndSub
EndClass


Tipo/Forms"

Aboutbox

PublicNotInheritableClassAboutBox
PrivateSub AboutBox_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) HandlesMyBase.Load
' Set the title of the form.
Dim ApplicationTitle AsString
IfMy.Application.Info.Title <> ""Then
ApplicationTitle = My.Application.Info.Title
Else
ApplicationTitle = System.IO.Path.GetFileNameWithoutExtension(My.Application.Info.AssemblyName)
EndIf
Me.Text = String.Format("About {0}", ApplicationTitle)
' Initialize all of the text displayed on the About Box.
' TODO: Customize the application's assembly information in the "Application" pane of the project
' properties dialog (under the "Project" menu).
Me.LabelProductName.Text = My.Application.Info.ProductName
Me.LabelVersion.Text = String.Format("Version {0}", My.Application.Info.Version.ToString)
Me.LabelCopyright.Text = My.Application.Info.Copyright
Me.LabelCompanyName.Text = My.Application.Info.CompanyName
Me.TextBoxDescription.Text = My.Application.Info.Description
EndSub
PrivateSub OKButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OKButton.Click
Me.Close()
EndSub
EndClass


"SplashScrem"


From"

Link

Imports System.Windows.Forms
PublicClassAbrirLocal
PrivateSub OK_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK_Button.Click
Me.DialogResult = System.Windows.Forms.DialogResult.OK
Me.Close()
EndSub
PrivateSub Cancel_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cancel_Button.Click
Me.DialogResult = System.Windows.Forms.DialogResult.Cancel
Me.Close()
EndSub
EndClass


espero que gostem abraço
 
Back
Topo