Web Browser History and Favourites

Do you need something made? then ask in here.
Forum rules
Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
9 posts Page 1 of 1
Contributors
User avatar
Robby
VIP - Donator
VIP - Donator
Posts: 417
Joined: Mon Aug 03, 2009 4:01 am

Web Browser History and Favourites
Robby
Hi there all i need help in making a web browser history and favourites as the title says ^^

By the way i m using a Tab Control and i used the ctype code thign in the tabbed browser so i really need ur help making tabbed browser history and favourites


I believe i saw a tutorial if i used a web browser control but im out of luck becuz i m using a tabbed web browser so please help me if u can :)

TY and regards,

Robby1998
My current Projects Listed Below:
Toixt++ Text Editor Just 10 or less more features to go!
Image
Image
User avatar
CodenStuff
Site Admin
Site Admin
Posts: 4389
Joined: Tue Aug 04, 2009 1:47 am

Hello,

Im not sure what you mean by history, you could use "Forward and Back" buttons to goto previous pages youve visted. Or do you want to save every single page you visit like internet explorer does?.

If you want to store favourite websites you could do something like this, for this im using a combobox to store the favourites:

Add a ComboBox and Button control to your form and use the following code:

For the ComboBox_SelectedIndexChanged event use:
Code: Select all
CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Navigate(ComboBox1.Text)
And for the button_click event use this:
Code: Select all
ComboBox1.Items.Add(CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Url.ToString)
        With ComboBox1
            Dim i As Integer
            Dim s As String = ""
            For i = 0 To .Items.Count - 1
                s += .Items(i).ToString & vbNewLine
            Next
            My.Computer.FileSystem.WriteAllText(Application.StartupPath & "\visurl.fav", s, False)
        End With
Then inside your Form_load event use this:
Code: Select all
 If My.Computer.FileSystem.FileExists(Application.StartupPath & "\visurl.fav") Then
            Using sr As New IO.StreamReader(Application.StartupPath & "\visurl.fav")
                Dim item As String = sr.ReadLine
                While item <> Nothing
                    ComboBox1.Items.Add(item)
                    item = sr.ReadLine
                End While
            End Using
        End If
What this code does is if you click the button you just added (save to favourites) it stores the page into the combobox and saves it to a file. Then when you select a page in the combobox it will load it into the selected browser tab. Also when the form first loads it will load your saved favourites into the combobox.

Hope thats the kindof thing you wanted, if not or you need anymore help please let me know cooll;
Welcome to CodenStuff.com Learn Code, Love Code. Thank you for being a member of the community.
User avatar
Robby
VIP - Donator
VIP - Donator
Posts: 417
Joined: Mon Aug 03, 2009 4:01 am

hi

o ok thx but is it possible to put it in a menu strip or justa combobox becuz i have tried it in menu strip and i will try it in the combobox


About the history i mean like Internet Explorer does it just like that

It will just open up a panel so in there there would be most visited links

like that so it is useful if u close it and then start it again and yea please help if u can

Ty and regads,

Robby1998
My current Projects Listed Below:
Toixt++ Text Editor Just 10 or less more features to go!
Image
Image
User avatar
CodenStuff
Site Admin
Site Admin
Posts: 4389
Joined: Tue Aug 04, 2009 1:47 am

Hello,

OK to put favourites into a menustrip control I would do something like this. Add a menustrip to your form and make a menu item called "Favourites" then add the following code to your project.

Inside the Form_load event add:
Code: Select all
If My.Computer.FileSystem.FileExists(Application.StartupPath & "\visurl.fav") Then
            Using sr As New IO.StreamReader(Application.StartupPath & "\visurl.fav")
                Dim item As String = sr.ReadLine
                While item <> Nothing
                    FavouritesToolStripMenuItem.DropDownItems.Add(item)
                    item = sr.ReadLine
                End While
            End Using
        End If
Then in the "Add to Favourites" button_click event add this:
Code: Select all
 FavouritesToolStripMenuItem.DropDownItems.Add(CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Url.ToString)

        With MenuStrip1
            Dim i As Integer
            Dim s As String = ""
            For i = 0 To FavouritesToolStripMenuItem.DropDownItems.Count - 1
                s += FavouritesToolStripMenuItem.DropDownItems(i).ToString & vbNewLine
            Next
            My.Computer.FileSystem.WriteAllText(Application.StartupPath & "\visurl.fav", s, False)
        End With
    End Sub
Then for the Favourite menu dropdownitem_click event use this:
Code: Select all
Private Sub FavouritesToolStripMenuItem_DropDownItemClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ToolStripItemClickedEventArgs) Handles FavouritesToolStripMenuItem.DropDownItemClicked
        CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Navigate(e.ClickedItem.Text.ToString)
    End Sub
That code will Add/Save and Load your favourites for the browser.

Now if you want to keep a history of every page you visit you could add a ListBox control somewhere on your form, wherever you want the history to be displayed and then use this code in your project.

Add this to the Form_load event:
Code: Select all
If My.Computer.FileSystem.FileExists(Application.StartupPath & "\history.nav") Then
            Using sr As New IO.StreamReader(Application.StartupPath & "\history.nav")
                Dim item As String = sr.ReadLine
                While item <> Nothing
                    ListBox1.Items.Add(item)
                    item = sr.ReadLine
                End While
            End Using
        End If
Add this into your tabpage browsers "DocumentCompleted" event:
Code: Select all
 ListBox1.Items.Add(CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Url.ToString)

        With ListBox1
            Dim i As Integer
            Dim s As String = ""
            For i = 0 To .Items.Count - 1
                s += .Items(i).ToString & vbNewLine
            Next
            My.Computer.FileSystem.WriteAllText(Application.StartupPath & "\history.nav", s, False)
        End With
Then add this code into the "ListBox_SelectedIndexChanged" event:
Code: Select all
CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Navigate(CType(sender, ListBox).SelectedItem.ToString)
That code will save every page you visit into the ListBox and Save/Load them with your browser.

Happy coding! cooll;
Welcome to CodenStuff.com Learn Code, Love Code. Thank you for being a member of the community.
User avatar
Robby
VIP - Donator
VIP - Donator
Posts: 417
Joined: Mon Aug 03, 2009 4:01 am

Re: Web Browser History and Favourites
Robby
hi there i have used the favourites one and it works perfectly and thx for that but as for the history one i cant find document completed for the tab control1 so please if you could help me or tell me what its real name is or how to get it at that point!


ty and regards,

Robby1998
My current Projects Listed Below:
Toixt++ Text Editor Just 10 or less more features to go!
Image
Image
User avatar
Robby
VIP - Donator
VIP - Donator
Posts: 417
Joined: Mon Aug 03, 2009 4:01 am

Re: Web Browser History and Favourites
Robby
o and also i need help in how to make a homepage using a textbox and a button


P.S sorry for asking too many question i m a beginner to VB so i m bad at it right now and i dont know much stuff so srry



Robby1998
My current Projects Listed Below:
Toixt++ Text Editor Just 10 or less more features to go!
Image
Image
User avatar
CodenStuff
Site Admin
Site Admin
Posts: 4389
Joined: Tue Aug 04, 2009 1:47 am

Hello,

If your browser uses tabs are you not creating the browsers dynamically?. If your only using 1 webbrowser control then it would go into "Webbrowser_documentcompleted" event.

For storing the home page I think your best most effective option is to save it in a setting. If you click "Project > Application Propertise> Settings" in the top navigation menu on VB then enter this setting with the value:

homepage - Value = http://www.google.com (or whichever page you want to be homepage)

Then in your project you could just add a "Set as Homepage" button and use this code in its click event:
Code: Select all
My.Settings.homepage = CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Url.ToString
My.Settings.Save()
Or you could add a textbox for the user to enter the homepage URL and in your "Set as Homepage" button click event use this code instead:
Code: Select all
My.Settings.homepage = TextBox??.Text ( The '??' needs replacing with the number of the textbox)
My.Settings.Save()
Then in the form_load event add this code at the top to load your homepage when the browser starts:
Code: Select all
CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Navigate(Convert.ToString(My.Settings.homepage))
And that should be it but it all depends on how your browser code is setup, If you send me the project files in a private message ill have a look at your code and see how best to add these features.

Happy coding! cooll;
Welcome to CodenStuff.com Learn Code, Love Code. Thank you for being a member of the community.
User avatar
Robby
VIP - Donator
VIP - Donator
Posts: 417
Joined: Mon Aug 03, 2009 4:01 am

Hello this is robby1998 here

ok i can send you my whole project but just to let you know my project is a big mess so yea i just have everrthing like all messed iin so it might be hard to look for stuff


if u ok wit that then i will send u the project



robby1998
My current Projects Listed Below:
Toixt++ Text Editor Just 10 or less more features to go!
Image
Image
User avatar
Robby
VIP - Donator
VIP - Donator
Posts: 417
Joined: Mon Aug 03, 2009 4:01 am

ok and i got a problem wit the homepage code please try to fix if u can and the project i sent u
My current Projects Listed Below:
Toixt++ Text Editor Just 10 or less more features to go!
Image
Image
9 posts Page 1 of 1
Return to “Tutorial Requests”