I've just recently run into a problem when programming a basic web-browser, when trying to make a bookmarks or favorites function.
To do this, the plan was to follow this structure:
1: A user visits the page they wish to bookmark and clicks "Bookmark This Page"
2: The Program takes the URL of the page and the document title (So it looks neat) and stores it in a 2D array.
3: The program then calls a function to refresh the favorites menu, which will clear it, then populate itself with the contents of the array.
This all works correctly, using the code below:
Private Sub BookmarkThisPageToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BookmarkThisPageToolStripMenuItem.Click
Dim Looprunner As Integer
For Looprunner = 1 To UBound(BookMarksArray, 1)
If BookMarksArray(Looprunner, 1) = tbURL.Text Then
GoTo Duplicate
Else
End If
Next
Add: BookmarksNum = BookmarksNum + 1
ReDim Preserve BookMarksArray(1, (BookmarksNum))
BookMarksArray(0, BookmarksNum) = BookmarksNum
BookMarksArray(1, (BookmarksNum)) = tbURL.Text
GoTo Complete
'MsgBox(MenuBar.Items.Count)
'Get the next available index in the menu
' Load(mnuBookmark(mnuBookmark.ubound + 1))
'Write the Caption of the new item as the URL
' mnuBookmark(mnuBookmark.ubound).Caption = Bookmark
Duplicate: MsgBox("There is Already a Bookmark Of this page")
Complete: Call UpdateFavourites()
End Sub
Sub UpdateFavourites()
On Error GoTo 0
For Loopcount = 1 To BookMarksArray.GetUpperBound(0)
'MnuFavourites.DropDownItems.Add(BookMarksArray(Loopcount, 1))
MnuFavourites.DropDownItems.Add(WB1.DocumentTitle)
Next Loopcount
End Sub
(Sorry about the messy format and Rem'd out lines, it's a work in progress).
Anywho, my problem is that, as you might imagine, clicking the items does nothing. As the menu items are generated at runtime, I cant seem to work out how to bind a click function to them (to navigate to their correct URL).
Thanks for the consideration.

Reply





MultiQuote





|