Tabbed Browser - How to add new tabs?

Hey,

I'm trying to create a simple web browser that supports tabbed browsing. (That is, using to tabs to open multiple windows without launching the program multiple times.) I have everything except the actual tab part complete.

I need to know how to add a tab and assign a web browser to it. I can get it to add the tab but assignning the browser as a child is beyond my knowledge. If at all possible a full example of a tabbed browser would be most effective for not only completing the task but also for me to learn how to do it. It that is not available any help would be just as highly appreciated.

I am using a TabControl and a WebBrowser for controls and both seem to work correctly. Other than that there are just the basic browser controls. I am using Microsft Visual Basic Express Edition on a Windows XP Pro Edition computer.

I would include code examples but I have no 'post-worthy' code to show. I hope you understand what my objective is.

Thank you in advance,

Matt


Here is a screenshot of the GUI:

http://img484.imageshack.us/img484/8667/ss5ko.png



Answer this question

Tabbed Browser - How to add new tabs?

  • toddhd

    Hi Matt, in addition to what you now have, there was a thread around here not so long ago about how to add a delete button to every tab which enabled you to remove specific tabs. Might be worth a quick search as the functionality might be a nice addition to your browser.

  • pwhitaker

    Yup, there's something your missing: SystemColors

    Use the code:

    Me.BackColor = SystemColors.Control

    That will give you access to all of the colors as specified by the current Windows color scheme.



  • cngzhnmrl

    Sorry to ask what is probably a basic question; but how do you add the event handlers in C#
  • R. Muti

    Thanks a lot!.

    Yeah, I'm doing this for learning purposes as well. The part I was stuck on was this single line of code:

    tab.Controls.Add(wb)

    So thanks again for solving that for me.

  • sniwas24x7

    Thank you very much.

    You browser looks awesome, very nice work. I appreciate the swift response as well.


  • Can-Ann

    I've got an example app that you can have. I guess the project is on my other PC so I'll post a link to it later tonight.

    In the meantime, here's a link to view a screen shot, and another to download the setup package.



  • eddy05

    Ok, that worked perfectly. Thanks. Now I'm trying to use multiple themes, I have the changing colors part down but restoring the controls to their original color ("Control") is where I'm stuck.

    I am using [#Control].BackColor = Color.[#Color] where [#] stands for the actual word. In the color list it only displays the web colors, not system colors. Is there something I'm missing, or a way around this

    Thanks in advance,

    Matt


  • Andrew Niemann

    Thank you for your suggestion, however I have discovered how to do this myself. But thank you anyway, it is helpful.

  • Dvorak

    OK, here a link to the WowserBrowser project.

    This is one of the first things I wrote in VS05.  Its not all that fancy as it was a proof of concept app coded mostly to learn and for fun.

    The code to add a new tab might look something like the following:

    Dim tab As New TabPage
    Dim wb As New WebBrowser

    wb.Dock = DockStyle.Fill

    AddHandler wb.CanGoBackChanged, AddressOf WebBrowser1_CanGoBackChanged
    AddHandler wb.CanGoForwardChanged, AddressOf WebBrowser1_CanGoForwardChanged
    AddHandler wb.DocumentCompleted, AddressOf WebBrowser1_DocumentCompleted
    AddHandler wb.DocumentTitleChanged, AddressOf WebBrowser1_DocumentTitleChanged
    AddHandler wb.EncryptionLevelChanged, AddressOf WebBrowser1_EncryptionLevelChanged
    AddHandler wb.ProgressChanged, AddressOf WebBrowser1_ProgressChanged
    AddHandler wb.StatusTextChanged, AddressOf WebBrowser1_StatusTextChanged
    AddHandler wb.Navigating, AddressOf WebBrowser1_Navigating
    AddHandler wb.Navigated, AddressOf WebBrowser1_Navigated

    tab.Controls.Add(wb)
    MainTabControl.TabPages.Add(tab)
    MainTabControl.SelectedTab = tab
    MainTabControl.SelectedTab.ImageIndex = 0

    CurBrowser = wb
    CurBrowser.GoHome()

    So basically I create a new TabPage and WebBrowser control, attach event handlers for the new browser, add the browser to the TabPage, add the TabPage to the TabControl and then make the new tab current.  There's some code omitted that you'll find in the project that deals with creating the thumbnail for the preview.

    The project isn't commented and there's some trial code that's commented out so if you have any trouble weeding through it, just let me know.

    HTH, GL!



  • Danny Thorpe MSFT

    Saved again by rkimble!

    Lol, thank you once again for instructing me.


  • Tabbed Browser - How to add new tabs?