VB.Net Tutorial/GUI/Browser — различия между версиями
Admin (обсуждение | вклад) м (1 версия) |
(нет различий)
|
Текущая версия на 15:56, 26 мая 2010
Create Your own browser based on DLL
<source lang="vbnet">Imports System.Runtime.InteropServices Imports System.Windows.Forms public class CreateYourOwnBrowserBasedOnDLL
public Shared Sub Main Application.Run(New Form1) End Sub
End class Public Class Form1
Dim szPath As String " Start\Program Public Const CSIDL_PROGRAMS As Short = &H2S " My Documents Public Const CSIDL_PERSONAL As Short = &H5S " {User}\Bookmark Windows NT Public Const CSIDL_FAVORITES As Short = &H6S " Start\Program\Boot Public Const CSIDL_STARTUP As Short = &H7S " {User}\Start Windows NT Public Const CSIDL_STARTMENU As Short = &HBS " {User}\Desktop Windows NT Public Const CSIDL_DESKTOPDIRECTORY As Short = &H10S " {Windows}\ShellNew Public Const CSIDL_TEMPLATES As Short = &H15S " All Users\Start Windows NT Public Const CSIDL_COMMON_STARTMENU As Short = &H16S " All Users\Program Windows NT Public Const CSIDL_COMMON_PROGRAMS As Short = &H17S " All Users\Boot Windows NT Public Const CSIDL_COMMON_STARTUP As Short = &H18S " All Users\Desktop Windows NT Public Const CSIDL_COMMON_DESKTOPDIRECTORY As Short = &H19S " {Windows}\Application Data Public Const CSIDL_APPDATA As Short = &H1AS " All Users\Bookmark Windows NT Public Const CSIDL_COMMON_FAVORITES As Short = &H1FS " All Users\Application Data Windows NT Public Const CSIDL_COMMON_APPDATA As Short = &H23S " nShowCmd Public Const SW_HIDE As Short = 0 Public Const SW_SHOWNORMAL As Short = 1 Public Const SW_SHOWMINIMIZED As Short = 2 Public Const SW_SHOWMAXIMIZED As Short = 3 Public Const SW_MAXIMIZE As Short = 3 Public Const SW_SHOWNOACTIVATE As Short = 4 Public Const SW_SHOW As Short = 5 Public Const SW_MINIMIZE As Short = 6 Public Const SW_SHOWMINNOACTIVE As Short = 7 Public Const SW_SHOWNA As Short = 8 Public Const SW_RESTORE As Short = 9 " Error Code Public Const ERROR_FILE_NOT_FOUND As Short = 2 Public Const ERROR_PATH_NOT_FOUND As Short = 3 Public Const ERROR_BAD_FORMAT As Short = 11 Public Const SE_ERR_FNF As Short = 2 Public Const SE_ERR_PNF As Short = 3 Public Const SE_ERR_ACCESSDENIED As Short = 5 Public Const SE_ERR_OOM As Short = 8 Public Const SE_ERR_SHARE As Short = 26 Public Const SE_ERR_ASSOCINCOMPLETE As Short = 27 Public Const SE_ERR_DDETIMEOUT As Short = 28 Public Const SE_ERR_DDEFAIL As Short = 29 Public Const SE_ERR_DDEBUSY As Short = 30 Public Const SE_ERR_NOASSOC As Short = 31 Public Const SE_ERR_DLLNOTFOUND As Short = 32 Public Const SHACF_DEFAULT As Integer = &H0S Public Const SHACF_FILESYSTEM As Integer = &H1S Public Const SHACF_URLHISTORY As Integer = &H2S Public Const SHACF_URLMRU As Integer = &H4S Public Const SHACF_USETAB As Integer = &H8S Public Const SHACF_FILESYS_ONLY As Integer = &H10S Public Const SHACF_AUTOSUGGEST_FORCE_ON As Integer = &H10000000 Public Const SHACF_AUTOSUGGEST_FORCE_OFF As Integer = &H20000000 Public Const SHACF_AUTOAPPEND_FORCE_ON As Integer = &H40000000 Public Const SHACF_AUTOAPPEND_FORCE_OFF As Integer = &H80000000 Public Const SHACF_URLALL As Integer = (SHACF_URLHISTORY Or SHACF_URLMRU) Public Declare Function SHAutoComplete Lib "Shlwapi.dll" _ (ByVal hwndEdit As Integer, _ ByVal dwFlags As Integer) As Integer
Public Declare Function DoAddToFavDlg _ Lib "shdocvw.dll" _ (ByVal hwnd As Integer, _ ByVal szPath As String, _ ByVal nSizeOfPath As Integer, _ ByVal szTitle As String, _ ByVal nSizeOfTitle As Integer, _ ByVal pidl As Integer) As Integer Public Declare Function SHGetSpecialFolderLocation _ Lib "shell32.dll" _ (ByVal hwndOwner As Integer, _ ByVal nFolder As Integer, _ ByRef pidl As Integer) As Integer Private Declare Function DoFileDownload Lib "shdocvw.dll" _ (ByVal lpszFile As String) As Integer
Public Declare Function WritePrivateProfileString _ Lib "kernel32" Alias "WritePrivateProfileStringA" _ (ByVal lpSectionName As String, _ ByVal lpKeyName As String, _ ByVal lpString As String, _ ByVal lpFileName As String) As Integer Public Declare Function DoOrganizeFavDlg _ Lib "shdocvw.dll" _ (ByVal hWnd As Integer, _ ByVal lpszRootFolder As String) As Integer Public Declare Function SHGetFolderPath _ Lib "shfolder.dll" Alias "SHGetFolderPathA" _ (ByVal hwndOwner As Integer, _ ByVal nFolder As Integer, _ ByVal hToken As Integer, _ ByVal dwReserved As Integer, _ ByVal lpszPath As String) As Integer Private Sub AutoComplete(ByVal check1 As Boolean, ByVal check2 As Boolean) Dim dwFlags As Integer If check1 Then dwFlags = SHACF_URLALL Or SHACF_FILESYSTEM Or _ SHACF_AUTOSUGGEST_FORCE_ON If check2 Then dwFlags = dwFlags Or SHACF_AUTOAPPEND_FORCE_ON Else dwFlags = dwFlags Or SHACF_AUTOAPPEND_FORCE_OFF End If Else dwFlags = SHACF_URLALL Or SHACF_FILESYSTEM Or _ SHACF_AUTOSUGGEST_FORCE_OFF If check2 Then dwFlags = dwFlags Or SHACF_AUTOAPPEND_FORCE_ON Else dwFlags = dwFlags Or SHACF_AUTOAPPEND_FORCE_OFF End If End If SHAutoComplete(TextBox1.Handle.ToInt32, dwFlags) End Sub Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load MenuStrip1.Top = 0 MenuStrip1.Left = 0 Panel1.Top = MenuStrip1.Height Panel1.Left = 0 Panel1.Width = Me.ClientSize.Width TextBox1.Width = Panel1.Width - TextBox1.Left - 5 WebBrowser1.Top = Panel1.Top + Panel1.Height WebBrowser1.Left = 0 WebBrowser1.Width = Me.ClientSize.Width WebBrowser1.Height = Me.ClientSize.Height - Panel1.Height - StatusStrip1.Height WebBrowser1.Navigate("c:\") End Sub Private Sub Form1_Resize(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Resize MenuStrip1.Top = 0 MenuStrip1.Left = 0 Panel1.Top = MenuStrip1.Height Panel1.Left = 0 Panel1.Width = Me.ClientSize.Width TextBox1.Width = Panel1.Width - TextBox1.Left - 5 WebBrowser1.Top = Panel1.Top + Panel1.Height WebBrowser1.Left = 0 WebBrowser1.Width = Me.ClientSize.Width WebBrowser1.Height = Me.ClientSize.Height - Panel1.Height - StatusStrip1.Height End Sub Private Sub BackBtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BackBtn.Click WebBrowser1.GoBack() End Sub Private Sub ForwardBtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ForwardBtn.Click WebBrowser1.GoForward() End Sub Private Sub StopBtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles StopBtn.Click WebBrowser1.Stop() End Sub Private Sub RefreshBtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RefreshBtn.Click WebBrowser1.Refresh() End Sub Private Sub HomeBtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles HomeBtn.Click WebBrowser1.GoHome() End Sub Private Sub SearchBtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SearchBtn.Click WebBrowser1.GoSearch() End Sub Private Sub TextBox1_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress If e.KeyChar = Microsoft.VisualBasic.ChrW(13) Then WebBrowser1.Navigate(TextBox1.Text) End If End Sub
Private Sub WebBrowser1_Navigated(ByVal sender As System.Object, ByVal e As System.Windows.Forms.WebBrowserNavigatedEventArgs) Handles WebBrowser1.Navigated TextBox1.Text = WebBrowser1.Url.ToString ToolStripStatusLabel1.Text = WebBrowser1.Url.ToString End Sub Private Sub ToolStripMenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripMenuItem1.Click Dim NewForm As New Form1() Dim strURL As String = WebBrowser1.Url.ToString NewForm.Show() NewForm.Focus() NewForm.WebBrowser1.Navigate(strURL) End Sub Private Sub ToolStripMenuItem2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripMenuItem2.Click OpenFileDialog1.Filter = "All Files (*.*)|*.*" OpenFileDialog1.Title = "Open" If OpenFileDialog1.ShowDialog() = DialogResult.OK Then WebBrowser1.Navigate(OpenFileDialog1.FileName) End If End Sub Private Sub ToolStripMenuItem3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripMenuItem3.Click Dim proc As New System.Diagnostics.Process() Dim SystemDir As String = System.Environment.SystemDirectory proc.Start(SystemDir & "\MOBSYNC.EXE") End Sub Private Sub ToolStripMenuItem4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripMenuItem4.Click Dim proc As New System.Diagnostics.Process() Dim SystemDir As String = System.Environment.SystemDirectory proc.Start("control.exe", "Inetcpl.cpl") End Sub Private Sub ToolStripMenuItem5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripMenuItem5.Click If TextBox1.Text <> "" Then WebBrowser1.Navigate("view-source:" & TextBox1.Text) End If End Sub Private Sub ToolStripMenuItemMail_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripMenuItemMail.Click WebBrowser1.Navigate("mailto:test@test.ru?cc=bbb@test.ru& bcc=ccc@test.ru&subject="mailto") End Sub Private Sub ToolStripMenuItem6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripMenuItem6.Click ToolStripMenuItem6.Checked = Not ToolStripMenuItem6.Checked AutoComplete(ToolStripMenuItem6.Checked, ToolStripMenuItem7.Checked) End Sub Private Sub ToolStripMenuItem7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripMenuItem7.Click ToolStripMenuItem7.Checked = Not ToolStripMenuItem7.Checked AutoComplete(ToolStripMenuItem6.Checked, ToolStripMenuItem7.Checked) End Sub Private Sub ToolStripMenuItem11_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripMenuItem11.Click Try DoFileDownload(TextBox1.Text) Catch ex As Exception MsgBox(ex.StackTrace.ToString()) End Try End Sub Private Sub ToolStripMenuItem9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripMenuItem9.Click Dim proc As New System.Diagnostics.Process() Dim SystemDir As String = System.Environment.SystemDirectory Dim szPath As String = "http://www.vbex.ru/" If szPath <> "" Then Try "rundll32.exe shdocvw.dll,OpenURL %l proc.Start("rundll32.exe", "shdocvw.dll,OpenURL " & szPath) Catch ex As Exception Console.WriteLine(ex.StackTrace.ToString()) End Try End If End Sub Private Sub ToolStripMenuItem8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripMenuItem8.Click Dim szTitle As String Dim dwReturn As Integer Dim pidl As Integer szTitle = "My Bookmark" & vbNullChar szPath = Space(256) & vbNullChar dwReturn = SHGetSpecialFolderLocation(Handle.ToInt32, _ CSIDL_FAVORITES, pidl) If dwReturn = 0 Then dwReturn = DoAddToFavDlg(Handle.ToInt32, szPath, _ Len(szPath), szTitle, Len(szTitle), pidl) If dwReturn = 1 Then szPath = szPath.Substring(0, szPath.IndexOf(vbNullChar)) WritePrivateProfileString("InternetShortcut", "URL", _ TextBox1.Text, szPath) End If End If End Sub Private Sub ToolStripMenuItem10_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripMenuItem10.Click Dim lpszRootFolder As String Dim lpszPath As String Dim dwReturn As Integer lpszPath = Space(256) dwReturn = SHGetFolderPath(Handle.ToInt32, _ CSIDL_FAVORITES, 0, &H0S, lpszPath) If dwReturn = 0 Then lpszRootFolder = lpszPath.Substring(0, _ lpszPath.IndexOf(vbNullChar)) End If DoOrganizeFavDlg(Handle.ToInt32, lpszRootFolder) End Sub
End Class
<Global.Microsoft.VisualBasic.rupilerServices.DesignerGenerated()> _ Partial Class Form1
Inherits System.Windows.Forms.Form "Form overrides dispose to clean up the component list. <System.Diagnostics.DebuggerNonUserCode()> _ Protected Overrides Sub Dispose(ByVal disposing As Boolean) If disposing AndAlso components IsNot Nothing Then components.Dispose() End If MyBase.Dispose(disposing) End Sub "Required by the Windows Form Designer Private components As System.ruponentModel.IContainer "NOTE: The following procedure is required by the Windows Form Designer "It can be modified using the Windows Form Designer. "Do not modify it using the code editor. <System.Diagnostics.DebuggerStepThrough()> _ Private Sub InitializeComponent() Me.Panel1 = New System.Windows.Forms.Panel Me.ToolStrip1 = New System.Windows.Forms.ToolStrip Me.BackBtn = New System.Windows.Forms.ToolStripButton Me.ForwardBtn = New System.Windows.Forms.ToolStripButton Me.StopBtn = New System.Windows.Forms.ToolStripButton Me.RefreshBtn = New System.Windows.Forms.ToolStripButton Me.HomeBtn = New System.Windows.Forms.ToolStripButton Me.SearchBtn = New System.Windows.Forms.ToolStripButton Me.Label1 = New System.Windows.Forms.Label Me.TextBox1 = New System.Windows.Forms.TextBox Me.ToolStripStatusLabel1 = New System.Windows.Forms.ToolStripStatusLabel Me.StatusStrip1 = New System.Windows.Forms.StatusStrip Me.OpenFileDialog1 = New System.Windows.Forms.OpenFileDialog Me.ToolStripMenuItem4 = New System.Windows.Forms.ToolStripMenuItem Me.ToolStripMenuItem3 = New System.Windows.Forms.ToolStripMenuItem Me.MenuItemFile = New System.Windows.Forms.ToolStripMenuItem Me.ToolStripMenuItem1 = New System.Windows.Forms.ToolStripMenuItem Me.ToolStripMenuItem2 = New System.Windows.Forms.ToolStripMenuItem Me.ToolStripMenuItem5 = New System.Windows.Forms.ToolStripMenuItem Me.ToolStripMenuItemMail = New System.Windows.Forms.ToolStripMenuItem Me.ToolStripMenuItem6 = New System.Windows.Forms.ToolStripMenuItem Me.ToolStripMenuItem7 = New System.Windows.Forms.ToolStripMenuItem Me.MenuStrip1 = New System.Windows.Forms.MenuStrip Me.ToolStripMenuItemFav = New System.Windows.Forms.ToolStripMenuItem Me.ToolStripMenuItem8 = New System.Windows.Forms.ToolStripMenuItem Me.ToolStripMenuItem9 = New System.Windows.Forms.ToolStripMenuItem Me.ToolStripMenuItem10 = New System.Windows.Forms.ToolStripMenuItem Me.ToolStripMenuItem11 = New System.Windows.Forms.ToolStripMenuItem Me.WebBrowser1 = New System.Windows.Forms.WebBrowser Me.Panel1.SuspendLayout() Me.ToolStrip1.SuspendLayout() Me.StatusStrip1.SuspendLayout() Me.MenuStrip1.SuspendLayout() Me.SuspendLayout() " "Panel1 " Me.Panel1.Controls.Add(Me.ToolStrip1) Me.Panel1.Controls.Add(Me.Label1) Me.Panel1.Controls.Add(Me.TextBox1) Me.Panel1.Location = New System.Drawing.Point(-4, 27) Me.Panel1.Name = "Panel1" Me.Panel1.Size = New System.Drawing.Size(546, 59) Me.Panel1.TabIndex = 11 " "ToolStrip1 " Me.ToolStrip1.Items.AddRange(New System.Windows.Forms.ToolStripItem() {Me.BackBtn, Me.ForwardBtn, Me.StopBtn, Me.RefreshBtn, Me.HomeBtn, Me.SearchBtn}) Me.ToolStrip1.Location = New System.Drawing.Point(0, 0) Me.ToolStrip1.Name = "ToolStrip1" Me.ToolStrip1.Size = New System.Drawing.Size(546, 25) Me.ToolStrip1.TabIndex = 11 Me.ToolStrip1.Text = "ToolStrip1" " "BackBtn " Me.BackBtn.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text Me.BackBtn.ImageTransparentColor = System.Drawing.Color.Magenta Me.BackBtn.Name = "BackBtn" Me.BackBtn.Size = New System.Drawing.Size(45, 22) Me.BackBtn.Text = "Back" " "ForwardBtn " Me.ForwardBtn.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text Me.ForwardBtn.ImageTransparentColor = System.Drawing.Color.Magenta Me.ForwardBtn.Name = "ForwardBtn" Me.ForwardBtn.Size = New System.Drawing.Size(45, 22) Me.ForwardBtn.Text = "Next" " "StopBtn " Me.StopBtn.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text Me.StopBtn.ImageTransparentColor = System.Drawing.Color.Magenta Me.StopBtn.Name = "StopBtn" Me.StopBtn.Size = New System.Drawing.Size(33, 22) Me.StopBtn.Text = "Stop" " "RefreshBtn " Me.RefreshBtn.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text Me.RefreshBtn.ImageTransparentColor = System.Drawing.Color.Magenta Me.RefreshBtn.Name = "RefreshBtn" Me.RefreshBtn.Size = New System.Drawing.Size(33, 22) Me.RefreshBtn.Text = "Refresh" " "HomeBtn " Me.HomeBtn.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text Me.HomeBtn.ImageTransparentColor = System.Drawing.Color.Magenta Me.HomeBtn.Name = "HomeBtn" Me.HomeBtn.Size = New System.Drawing.Size(45, 22) Me.HomeBtn.Text = "Home" " "SearchBtn " Me.SearchBtn.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text Me.SearchBtn.ImageTransparentColor = System.Drawing.Color.Magenta Me.SearchBtn.Name = "SearchBtn" Me.SearchBtn.Size = New System.Drawing.Size(45, 22) Me.SearchBtn.Text = "Search" " "Label1 " Me.Label1.Location = New System.Drawing.Point(5, 28) Me.Label1.Name = "Label1" Me.Label1.Size = New System.Drawing.Size(60, 18) Me.Label1.TabIndex = 10 Me.Label1.Text = "URL:" " "TextBox1 " Me.TextBox1.Location = New System.Drawing.Point(71, 28) Me.TextBox1.Name = "TextBox1" Me.TextBox1.Size = New System.Drawing.Size(463, 21) Me.TextBox1.TabIndex = 9 Me.TextBox1.Text = "c:\" " "ToolStripStatusLabel1 " Me.ToolStripStatusLabel1.Name = "ToolStripStatusLabel1" Me.ToolStripStatusLabel1.Size = New System.Drawing.Size(23, 17) Me.ToolStripStatusLabel1.Text = "c:\" " "StatusStrip1 " Me.StatusStrip1.Items.AddRange(New System.Windows.Forms.ToolStripItem() {Me.ToolStripStatusLabel1}) Me.StatusStrip1.Location = New System.Drawing.Point(0, 228) Me.StatusStrip1.Name = "StatusStrip1" Me.StatusStrip1.Size = New System.Drawing.Size(541, 22) Me.StatusStrip1.TabIndex = 10 " "OpenFileDialog1 " Me.OpenFileDialog1.FileName = "OpenFileDialog1" " "ToolStripMenuItem4 " Me.ToolStripMenuItem4.Name = "ToolStripMenuItem4" Me.ToolStripMenuItem4.Size = New System.Drawing.Size(202, 22) Me.ToolStripMenuItem4.Text = "IE Option" " "ToolStripMenuItem3 " Me.ToolStripMenuItem3.Name = "ToolStripMenuItem3" Me.ToolStripMenuItem3.Size = New System.Drawing.Size(202, 22) Me.ToolStripMenuItem3.Text = "Concurrent" " "MenuItemFile " Me.MenuItemFile.DropDownItems.AddRange(New System.Windows.Forms.ToolStripItem() {Me.ToolStripMenuItem1, Me.ToolStripMenuItem2, Me.ToolStripMenuItem3, Me.ToolStripMenuItem4, Me.ToolStripMenuItem5, Me.ToolStripMenuItemMail, Me.ToolStripMenuItem6, Me.ToolStripMenuItem7}) Me.MenuItemFile.Name = "MenuItemFile" Me.MenuItemFile.Size = New System.Drawing.Size(41, 20) Me.MenuItemFile.Text = "File" " "ToolStripMenuItem1 " Me.ToolStripMenuItem1.Name = "ToolStripMenuItem1" Me.ToolStripMenuItem1.Size = New System.Drawing.Size(202, 22) Me.ToolStripMenuItem1.Text = "New" " "ToolStripMenuItem2 " Me.ToolStripMenuItem2.Name = "ToolStripMenuItem2" Me.ToolStripMenuItem2.Size = New System.Drawing.Size(202, 22) Me.ToolStripMenuItem2.Text = "Open" " "ToolStripMenuItem5 " Me.ToolStripMenuItem5.Name = "ToolStripMenuItem5" Me.ToolStripMenuItem5.Size = New System.Drawing.Size(202, 22) Me.ToolStripMenuItem5.Text = "Source" " "ToolStripMenuItemMail " Me.ToolStripMenuItemMail.Name = "ToolStripMenuItemMail" Me.ToolStripMenuItemMail.Size = New System.Drawing.Size(202, 22) Me.ToolStripMenuItemMail.Text = "Email" " "ToolStripMenuItem6 " Me.ToolStripMenuItem6.Name = "ToolStripMenuItem6" Me.ToolStripMenuItem6.Size = New System.Drawing.Size(202, 22) Me.ToolStripMenuItem6.Text = "Suggestion" " "ToolStripMenuItem7 " Me.ToolStripMenuItem7.Name = "ToolStripMenuItem7" Me.ToolStripMenuItem7.Size = New System.Drawing.Size(202, 22) Me.ToolStripMenuItem7.Text = "Append" " "MenuStrip1 " Me.MenuStrip1.Items.AddRange(New System.Windows.Forms.ToolStripItem() {Me.MenuItemFile, Me.ToolStripMenuItemFav}) Me.MenuStrip1.Location = New System.Drawing.Point(0, 0) Me.MenuStrip1.Name = "MenuStrip1" Me.MenuStrip1.Size = New System.Drawing.Size(541, 24) Me.MenuStrip1.TabIndex = 9 Me.MenuStrip1.Text = "MenuStrip1" " "ToolStripMenuItemFav " Me.ToolStripMenuItemFav.DropDownItems.AddRange(New System.Windows.Forms.ToolStripItem() {Me.ToolStripMenuItem8, Me.ToolStripMenuItem9, Me.ToolStripMenuItem10, Me.ToolStripMenuItem11}) Me.ToolStripMenuItemFav.Name = "ToolStripMenuItemFav" Me.ToolStripMenuItemFav.Size = New System.Drawing.Size(53, 20) Me.ToolStripMenuItemFav.Text = "Bookmark" " "ToolStripMenuItem8 " Me.ToolStripMenuItem8.Name = "ToolStripMenuItem8" Me.ToolStripMenuItem8.Size = New System.Drawing.Size(190, 22) Me.ToolStripMenuItem8.Text = "Add Bookmark" " "ToolStripMenuItem9 " Me.ToolStripMenuItem9.Name = "ToolStripMenuItem9" Me.ToolStripMenuItem9.Size = New System.Drawing.Size(190, 22) Me.ToolStripMenuItem9.Text = "Internet URL Shortcut" " "ToolStripMenuItem10 " Me.ToolStripMenuItem10.Name = "ToolStripMenuItem10" Me.ToolStripMenuItem10.Size = New System.Drawing.Size(190, 22) Me.ToolStripMenuItem10.Text = "Organize" " "ToolStripMenuItem11 " Me.ToolStripMenuItem11.Name = "ToolStripMenuItem11" Me.ToolStripMenuItem11.Size = New System.Drawing.Size(190, 22) Me.ToolStripMenuItem11.Text = "Download File" " "WebBrowser1 " Me.WebBrowser1.Location = New System.Drawing.Point(5, 93) Me.WebBrowser1.MinimumSize = New System.Drawing.Size(20, 20) Me.WebBrowser1.Name = "WebBrowser1" Me.WebBrowser1.Size = New System.Drawing.Size(536, 120) Me.WebBrowser1.TabIndex = 12 " "Form1 " Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 12.0!) Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font Me.ClientSize = New System.Drawing.Size(541, 250) Me.Controls.Add(Me.WebBrowser1) Me.Controls.Add(Me.Panel1) Me.Controls.Add(Me.StatusStrip1) Me.Controls.Add(Me.MenuStrip1) Me.Panel1.ResumeLayout(False) Me.Panel1.PerformLayout() Me.ToolStrip1.ResumeLayout(False) Me.ToolStrip1.PerformLayout() Me.StatusStrip1.ResumeLayout(False) Me.StatusStrip1.PerformLayout() Me.MenuStrip1.ResumeLayout(False) Me.MenuStrip1.PerformLayout() Me.ResumeLayout(False) Me.PerformLayout() End Sub Friend WithEvents Panel1 As System.Windows.Forms.Panel Friend WithEvents ToolStrip1 As System.Windows.Forms.ToolStrip Friend WithEvents BackBtn As System.Windows.Forms.ToolStripButton Friend WithEvents ForwardBtn As System.Windows.Forms.ToolStripButton Friend WithEvents StopBtn As System.Windows.Forms.ToolStripButton Friend WithEvents RefreshBtn As System.Windows.Forms.ToolStripButton Friend WithEvents HomeBtn As System.Windows.Forms.ToolStripButton Friend WithEvents SearchBtn As System.Windows.Forms.ToolStripButton Friend WithEvents Label1 As System.Windows.Forms.Label Friend WithEvents TextBox1 As System.Windows.Forms.TextBox Friend WithEvents ToolStripStatusLabel1 As System.Windows.Forms.ToolStripStatusLabel Friend WithEvents StatusStrip1 As System.Windows.Forms.StatusStrip Friend WithEvents OpenFileDialog1 As System.Windows.Forms.OpenFileDialog Friend WithEvents ToolStripMenuItem4 As System.Windows.Forms.ToolStripMenuItem Friend WithEvents ToolStripMenuItem3 As System.Windows.Forms.ToolStripMenuItem Friend WithEvents MenuItemFile As System.Windows.Forms.ToolStripMenuItem Friend WithEvents ToolStripMenuItem1 As System.Windows.Forms.ToolStripMenuItem Friend WithEvents ToolStripMenuItem2 As System.Windows.Forms.ToolStripMenuItem Friend WithEvents ToolStripMenuItem5 As System.Windows.Forms.ToolStripMenuItem Friend WithEvents MenuStrip1 As System.Windows.Forms.MenuStrip Friend WithEvents ToolStripMenuItem6 As System.Windows.Forms.ToolStripMenuItem Friend WithEvents ToolStripMenuItem7 As System.Windows.Forms.ToolStripMenuItem Friend WithEvents ToolStripMenuItemFav As System.Windows.Forms.ToolStripMenuItem Friend WithEvents ToolStripMenuItem8 As System.Windows.Forms.ToolStripMenuItem Friend WithEvents ToolStripMenuItem9 As System.Windows.Forms.ToolStripMenuItem Friend WithEvents ToolStripMenuItem10 As System.Windows.Forms.ToolStripMenuItem Friend WithEvents ToolStripMenuItem11 As System.Windows.Forms.ToolStripMenuItem Friend WithEvents WebBrowser1 As System.Windows.Forms.WebBrowser Friend WithEvents ToolStripMenuItemMail As System.Windows.Forms.ToolStripMenuItem
End Class</source>
Use LinkLabel to start a browser
<source lang="vbnet">Imports System.Windows.Forms public class LinkLableSample
public Shared Sub Main Application.Run(New Form1) End Sub
End class Public Class Form1
Inherits System.Windows.Forms.Form Public Sub New() MyBase.New() InitializeComponent() End Sub Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing Then If Not (components Is Nothing) Then components.Dispose() End If End If MyBase.Dispose(disposing) End Sub Private components As System.ruponentModel.IContainer Friend WithEvents LinkLabel1 As System.Windows.Forms.LinkLabel <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() Me.LinkLabel1 = New System.Windows.Forms.LinkLabel Me.SuspendLayout() " "LinkLabel1 " Me.LinkLabel1.Font = New System.Drawing.Font("Microsoft Sans Serif", 15.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.LinkLabel1.Location = New System.Drawing.Point(88, 32) Me.LinkLabel1.Name = "LinkLabel1" Me.LinkLabel1.Size = New System.Drawing.Size(112, 32) Me.LinkLabel1.TabIndex = 0 Me.LinkLabel1.TabStop = True Me.LinkLabel1.Text = "vbex.ru" " "Form1 " Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.ClientSize = New System.Drawing.Size(292, 102) Me.Controls.Add(Me.LinkLabel1) Me.ResumeLayout(False) End Sub Private Sub LinkLabel1_LinkClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles LinkLabel1.LinkClicked sender.linkVisited = True System.Diagnostics.Process.Start("http://www.vbex.ru") End Sub
End Class</source>
WebBrowser Demo
<source lang="vbnet">Imports System.Windows.Forms public class WebBrowserDemo
public Shared Sub Main Application.Run(New Form1) End Sub
End class Public Class Form1
Private Sub txtURL_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles txtURL.KeyDown If (e.KeyCode = Keys.Enter) Then WebBrowser1.Navigate(txtURL.Text) End If End Sub Private Sub btnBack_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnBack.Click WebBrowser1.GoBack() End Sub Private Sub btnForward_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnForward.Click WebBrowser1.GoForward() End Sub Private Sub btnHome_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnHome.Click WebBrowser1.GoHome() End Sub
End Class <Global.Microsoft.VisualBasic.rupilerServices.DesignerGenerated()> _ Partial Class Form1
Inherits System.Windows.Forms.Form "Form overrides dispose to clean up the component list. <System.Diagnostics.DebuggerNonUserCode()> _ Protected Overrides Sub Dispose(ByVal disposing As Boolean) If disposing AndAlso components IsNot Nothing Then components.Dispose() End If MyBase.Dispose(disposing) End Sub "Required by the Windows Form Designer Private components As System.ruponentModel.IContainer "NOTE: The following procedure is required by the Windows Form Designer "It can be modified using the Windows Form Designer. "Do not modify it using the code editor. <System.Diagnostics.DebuggerStepThrough()> _ Private Sub InitializeComponent() Me.ToolStrip1 = New System.Windows.Forms.ToolStrip Me.ToolStripLabel1 = New System.Windows.Forms.ToolStripLabel Me.txtURL = New System.Windows.Forms.ToolStripTextBox Me.btnBack = New System.Windows.Forms.ToolStripButton Me.btnForward = New System.Windows.Forms.ToolStripButton Me.btnHome = New System.Windows.Forms.ToolStripButton Me.WebBrowser1 = New System.Windows.Forms.WebBrowser Me.ToolStrip1.SuspendLayout() Me.SuspendLayout() " "ToolStrip1 " Me.ToolStrip1.Items.AddRange(New System.Windows.Forms.ToolStripItem() {Me.ToolStripLabel1, Me.txtURL, Me.btnBack, Me.btnForward, Me.btnHome}) Me.ToolStrip1.Location = New System.Drawing.Point(0, 0) Me.ToolStrip1.Name = "ToolStrip1" Me.ToolStrip1.Size = New System.Drawing.Size(703, 25) Me.ToolStrip1.TabIndex = 0 Me.ToolStrip1.Text = "ToolStrip1" " "ToolStripLabel1 " Me.ToolStripLabel1.Name = "ToolStripLabel1" Me.ToolStripLabel1.Size = New System.Drawing.Size(50, 22) Me.ToolStripLabel1.Text = "Address:" " "txtURL " Me.txtURL.Name = "txtURL" Me.txtURL.Size = New System.Drawing.Size(200, 25) " "btnBack " Me.btnBack.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text Me.btnBack.ImageTransparentColor = System.Drawing.Color.Magenta Me.btnBack.Name = "btnBack" Me.btnBack.Size = New System.Drawing.Size(33, 22) Me.btnBack.Text = "Back" " "btnForward " Me.btnForward.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text Me.btnForward.ImageTransparentColor = System.Drawing.Color.Magenta Me.btnForward.Name = "btnForward" Me.btnForward.Size = New System.Drawing.Size(51, 22) Me.btnForward.Text = "Forward" " "btnHome " Me.btnHome.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text Me.btnHome.ImageTransparentColor = System.Drawing.Color.Magenta Me.btnHome.Name = "btnHome" Me.btnHome.Size = New System.Drawing.Size(38, 22) Me.btnHome.Text = "Home" " "WebBrowser1 " Me.WebBrowser1.Dock = System.Windows.Forms.DockStyle.Fill Me.WebBrowser1.Location = New System.Drawing.Point(0, 25) Me.WebBrowser1.MinimumSize = New System.Drawing.Size(20, 20) Me.WebBrowser1.Name = "WebBrowser1" Me.WebBrowser1.Size = New System.Drawing.Size(703, 429) Me.WebBrowser1.TabIndex = 1 " "Form1 " Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font Me.ClientSize = New System.Drawing.Size(703, 454) Me.Controls.Add(Me.WebBrowser1) Me.Controls.Add(Me.ToolStrip1) Me.Name = "Form1" Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen Me.Text = "MyBrowser" Me.ToolStrip1.ResumeLayout(False) Me.ToolStrip1.PerformLayout() Me.ResumeLayout(False) Me.PerformLayout() End Sub Friend WithEvents ToolStrip1 As System.Windows.Forms.ToolStrip Friend WithEvents WebBrowser1 As System.Windows.Forms.WebBrowser Friend WithEvents ToolStripLabel1 As System.Windows.Forms.ToolStripLabel Friend WithEvents txtURL As System.Windows.Forms.ToolStripTextBox Friend WithEvents btnBack As System.Windows.Forms.ToolStripButton Friend WithEvents btnForward As System.Windows.Forms.ToolStripButton Friend WithEvents btnHome As System.Windows.Forms.ToolStripButton
End Class</source>