Hi again...
I have been working on a small webbrowser application, and am having trouble with my Favorites bar script.
So far I have
Public Class frm_Main
Public Function NewFav(ByVal Name As String, ByVal URL As Uri)
Dim twoToolStripMenuItem As ToolStripMenuItem = New ToolStripMenuItem(Name)
AddHandler twoToolStripMenuItem.Click, AddressOf Me.twoToolStripMenuItem_Click
Me.FavoritesToolStripMenuItem.DropDownItems.Add(twoToolStripMenuItem)
End Function
Private Sub twoToolStripMenuItem_Click(ByVal sender As Object, ByVal e As EventArgs)
'd3rp
End Sub
Private Sub btn_AddFav_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_AddFav.Click
frm_NewFav.Show()
frm_NewFav.tbx_URL.Text = wbb_Internet.Url.ToString()
End Sub
Private Sub btn_WebBack_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_WebBack.Click
wbb_Internet.GoBack()
tbx_Address.Text = wbb_Internet.Url.ToString()
End Sub
Private Sub btn_WebFwd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_WebFwd.Click
wbb_Internet.GoForward()
tbx_Address.Text = wbb_Internet.Url.ToString()
End Sub
Private Sub btn_WebGo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_WebGo.Click
wbb_Internet.Navigate(New Uri(tbx_Address.Text))
End Sub
Private Sub btn_WebStop_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_WebStop.Click
wbb_Internet.Stop()
End Sub
Private Sub wbb_Internet_Navigated(ByVal sender As System.Object, ByVal e As System.Windows.Forms.WebBrowserNavigatedEventArgs) Handles wbb_Internet.Navigated
tbx_Address.Text = wbb_Internet.Url.ToString
End Sub
End Class
Public Class frm_NewFav
Private Sub btn_Cancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_Cancel.Click
Me.Close()
End Sub
Private Sub btn_Create_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_Create.Click
Dim name As String = tbx_Name.Text
Dim URL As New Uri(tbx_URL.Text)
frm_Main.NewFav(name, URL)
End Sub
Private Sub frm_NewFav_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
tbx_URL.Text = frm_Main.wbb_Internet.Url.ToString
End Sub
Private Sub FavoriteAct()
frm_Main.wbb_Internet.Navigate(New Uri(tbx_URL.Text))
End Sub
End Class
But this is no working the way I need it to. My plan is that when a user opens the browser, and clicks on the Add Favorite button (btn_AddFav) the application opens a new window that asks for the name of the favorite and shows the current URL, which can be changed. Then, the application when you press create, (should) adds a new item in the MenuBar (MenuStrip1) under the favorites tab (FavoritesToolStripMenuItem). I have that part down. My problem is figuring out how I can make a generic hanler creation event so I can have new favorites create their own programming. So far, I have
Public Function NewFav(ByVal Name As String, ByVal URL As Uri)
Dim twoToolStripMenuItem As ToolStripMenuItem = New ToolStripMenuItem(Name)
AddHandler twoToolStripMenuItem.Click, AddressOf Me.twoToolStripMenuItem_Click
Me.FavoritesToolStripMenuItem.DropDownItems.Add(twoToolStripMenuItem)
End Function
which pulls the Name and URL from the NewFav form. It does add the Handler, but I don't think it is going to be able to make as many favorites as the user could want, so I could use a little help. My objective is to get a version of AddHandler to be able to create Subs that would tell the webbrowser (wbb_Internet) to go to a specific URL.
Thanks in advance!