• Log in or sign up for an account here: https://www.sythe.org/login

[Source] Adding Browser and tab controls at runtime

Swan

When They Cry...
Joined
Jan 23, 2007
Sythe Gold
0
Messages
4,957
Age
32
Location
Australia
[Source] Adding Browser and tab controls at runtime
Well, heres a source I decided to write tonight, 11 PM as it happens to be.

I was really quite annoyed at how much RAM common browsers such as IE and FireFox consumed, so I thought, "Why not make my own browser, which would be much smaller, and would still do what I want it to do?" so I started searching for things on how to make the features.

Here is something that a lot of people might like to use, whether it be for runescape clients and worldswitchers, or whether you want to make a practical application like what I'm doing at the moment.

Requirements:
Form named Form1
Tab Control named TabControl1


Here is the code:
Code:
    Dim MyWeb As WebBrowser

    Private Sub Form1_Load(ByVal sender As System.Object, _
    ByVal e As System.EventArgs) Handles MyBase.Load

        AddTab("tabpagelol")
        AddTab("omglol")

    End Sub

    Private Sub MyWeb_Navigated(ByVal sender As Object, ByVal e As System.Windows.Forms.WebBrowserNavigatedEventArgs)
        MsgBox("MyWeb Navigated fine!")
    End Sub

    Sub AddTab(ByVal TabName As String)
        Dim i As Integer
        TabControl1.TabPages.Add(TabName)
        i = TabControl1.TabCount - 1
        MyWeb = New WebBrowser
        MyWeb.Parent = TabControl1.TabPages.Item(i)
        'MyWeb.Size = New Size(Width, Height)
        MyWeb.Visible = True
        MyWeb.Dock = DockStyle.Fill
        AddHandler MyWeb.Navigated, AddressOf MyWeb_Navigated
        MyWeb.GoHome()
    End Sub

Remember, if you want to add more event handlers to "MyWeb", you must first have them coded in to avoid errors. The easiest way to do this would be to get the actual control from the toolbox, and copy and past the event handlers there (cut off the handles blabla off the end).

Happy coding! Edit this to do your bidding, I don't care, but add credit if you must, remembering that I did googling and studies to get this for myself!
 
[Source] Adding Browser and tab controls at runtime
very nice code, however not even googling was required :) just remember that vb.net has object orientation :D
 
[Source] Adding Browser and tab controls at runtime
Yup - I'd like to see something that does this so simple in VB6
 
[Source] Adding Browser and tab controls at runtime
may i suggest adding something similar to this line of code:
Code:
tabpage1.text = webbrowser1.documenttitle ' changes the tabpage text to the websites text =)

but besides for that you did a good job.
 
Runescape Gamblingrunescape gambling
Back
Top