[Source] Adding Browser and tab controls at runtime

Discussion in 'Programming General' started by Swan, Mar 17, 2007.

[Source] Adding Browser and tab controls at runtime
  1. Unread #1 - Mar 17, 2007 at 8:59 AM
  2. Swan
    Joined:
    Jan 23, 2007
    Posts:
    4,957
    Referrals:
    0
    Sythe Gold:
    0
    Sythe's 10th Anniversary Member of the Month Winner

    Swan When They Cry...
    Retired Global Moderator

    [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!
     
  3. Unread #2 - Mar 17, 2007 at 10:08 AM
  4. speljohan
    Joined:
    Apr 24, 2005
    Posts:
    1,450
    Referrals:
    3
    Sythe Gold:
    0

    speljohan Guru
    Visual Basic Programmers

    [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
     
  5. Unread #3 - Mar 17, 2007 at 8:25 PM
  6. Swan
    Joined:
    Jan 23, 2007
    Posts:
    4,957
    Referrals:
    0
    Sythe Gold:
    0
    Sythe's 10th Anniversary Member of the Month Winner

    Swan When They Cry...
    Retired Global Moderator

    [Source] Adding Browser and tab controls at runtime

    Yup - I'd like to see something that does this so simple in VB6
     
  7. Unread #4 - Oct 19, 2007 at 3:31 AM
  8. skate4lifee
    Joined:
    Jul 22, 2007
    Posts:
    108
    Referrals:
    1
    Sythe Gold:
    0

    skate4lifee Active Member

    [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.
     
< Tab help + redisgn forms at runtime. | Help registering Express version >

Users viewing this thread
1 guest


 
 
Adblock breaks this site