hi all .could any one show me how i can create dynamic tabs like firfox browser tabs. So when i press the + sign it creates a new tab with new browser controle there .Looking forward for reply.Thanks
Re: How to make dynamic firefox type browser tabs ?
I suppose that'd depend on what tab control you're using, or if you want to use one at all. You could easily make a command button control array to do this.
What is the problem, exactly?
Sure, create a command button(cmdTab), set the index to zero. Have another command button(cmdNewTab), set it's caption to +.
In the cmdNewTab_Click event:
Code:
Dim lGap As Long
Load cmdTab(cmdTab.Count)
lGap = 45 '45 twips is typically 3 pixels
cmdTab(cmdTab.UBound).Left = cmdTab(cmdTab.UBound - 1).Left + cmdTab(cmdTab.UBound).Width + lGap
cmdTab(cmdTab.UBound).Visible = True
I offer this, as they support the graphical Style, so you can use your own images for your tabs, so they look however you like!
Re: How to make dynamic firefox type browser tabs ?
Tony
Maybe something like this ...
On your form you need:
CommandButton named cbAddTab
SSTab control named SSTab1, with default Tabs = 3
WebBrowser control named WB1, placed on Tab 0, Index set to 0
Code:
' in declarations
Public nnTABS As Integer
' the sub
Private Sub cbAddTab_Click()
With SSTab1
' 1. first time it is clicked - sets up the controls
If nnTABs = 0 Then
nnTABs = nnTABs + 1
.Visible = True
.Top = 4500
.Left = 5500
.Width = 10000
.Height = 7000
.Tabs = 1
.TabsPerRow = 10
.TabMaxWidth = 1000
With WB1(0)
.Top = 1000
.Left = 500
.Height = 5500
.Width = 9000
.Visible = True
.Navigate2 "cme.com"
End With
' 2 subsequent clicks -- adds new tab and browser instance
ElseIf nnTABs > 0 Then
nnTABs = nnTABs + 1
With SSTab1
.Tabs = nnTABs
.Tab = nnTABs - 1
End With
Load WB1(nnTABs - 1)
With WB1(nnTABs - 1)
.Container = SSTab1
.Top = 1000
.Left = 500
.Height = 5500
.Width = 9000
.Visible = True
If nnTABs = 2 Then
.Navigate2 "yahoo.com"
ElseIf nnTABs = 3 Then
.Navigate2 "google.com"
ElseIf nnTABs = 4 Then
.Navigate2 "vbforums.com"
End If
End With
End If
End With
End Sub
A few comments are in order
I hardwired the URLs (highlighted in blue) -- you'll probably want to make your app smarter
I only defined things up to 4 tabs, so you might want to do more
When cbAddTab is clicked first time, only 1 Tab appears
With each subsequent click, a new tab is added
At any time you can click an extisting tab and it will show it's "own" browser
Natch, you'll want to adapt .Top, .Left, etc to suit your needs
BTW, I actually tested this, and it works !!
Hopefully this will get you started.
Re: How to make dynamic firefox type browser tabs ?
Many thanks spoo it worked well .But i want to load html files from a listbox when i click listbox items. could you show me how i can load these html urls in diffrent tabs when clicked on them ?
Code:
Private Sub List1_Click()
Form1.WebBrowser1.Navigate App.Path & "/" & List2.List(List1.ListIndex)
End Sub
Furthermore, how to add listbox item value beside tab numbers so i know which tab belongs to what item in listbox and lastly how to close a perticuler tab ?
Re: How to make dynamic firefox type browser tabs ?
Thanks for your reply.one of the listbox in the right side has the html file path like /htmls/sport.html
and the other listbox has the name like "sport activity".So when i click on sport activity it should load /htmls/sport.html into an empty tab if the no empty tab exist make new one ...
Re: How to make dynamic firefox type browser tabs ?
Tony
See if this works for you
On your form you'll need:
CommandButton named cbAddTab
ListBox named List1 << new
SSTab control named SSTab1, with default Tabs = 3
WebBrowser control named WB1, placed on Tab 0, Index set to 0
CommandButton named cbQuit, placed on Tab 0, Index set to 0 << new
Code:
' 1. in declarations
Public nnTABS As Integer
' 2. the initial load sub
Private Sub cbAddTab_Click()
With List1
.Top = 4500
.Left = 4000
.Height = 1000
.Width = 1300
.Visible = True
.AddItem "cme.com", 0
.AddItem "yahoo.com", 1
.AddItem "google.com", 2
.AddItem "vbforums.com", 3
End With
With SSTab1
If nnTABs = 0 Then
.Visible = True
.Top = 4500
.Left = 5500
.Width = 10000
.Height = 7000
.Tabs = 1
.TabsPerRow = 10
.TabMaxWidth = 1000
End If
End With
End Sub
' 3. click sub
Private Sub List1_Click()
'
' populate SSTab1, WB1(nnTABs)
'
With List1
v1 = .ListIndex
v2 = .List(v1)
nnTABs = nnTABs + 1
' Tab
With SSTab1
.Tabs = nnTABs
.Tab = nnTABs - 1
.Caption = Left(v2, InStr(v2, ".") - 1)
End With
' WB1
If nnTABs > 1 Then
Load WB1(nnTABs - 1)
End If
With WB1(nnTABs - 1)
.Container = SSTab1
.Top = 1000
.Left = 500
.Height = 5500
.Width = 9000
.Visible = True
.StatusBar = True
.MenuBar = True
.Navigate2 v2
End With
' cbQuit
If nnTABs > 1 Then
Load cbQuit(nnTABs - 1)
End If
With cbQuit(nnTABs - 1)
.Container = SSTab1
.Top = 500
.Left = 500
.Height = 300
.Width = 900
.Visible = True
End With
End With
End Sub
' 4. quit sub
Private Sub cbQuit_Click(Index As Integer)
'
' NOTE: only quits if on LAST tab
'
' last tab when only 1 tab
If nnTABs = 1 Then
nnTABs = 0
WB1(0).Visible = False
' last tab when >1 tabs
ElseIf nnTABs > 1 And Index = nnTABs - 1 Then
With WB1(nnTABs - 1)
.Stop
End With
If nnTABs > 1 Then
Unload WB1(nnTABs - 1)
Unload cbQuit(nnTABs - 1)
nnTABs = nnTABs - 1
With SSTab1
.Tabs = nnTABs
.Tab = nnTABs - 1
End With
End If
End If
End Sub
A few comments:
Code in sub cbAddTab has changed (it only loads the List and SSTab)
I hard-wired the URLs in the ListBox. You will need code to populate it
You can click them in any order to add to the set of tabs
Tab name is derived from just looking for the 1st "." in the string
Quit button only works if it is the LAST tab... it will "remove" the Tab
You are kinda pushing my knowledge-base here.
There well may be better ways to do this, but at least this is a start.
Below is a cropped image to give you an idea of how this will look
EDIT:
Ha! You snuck in a post while I was composing.
Well, this should still serve as a starting point for you
Re: How to make dynamic firefox type browser tabs ?
The error occur on inside WB1 List1_Click.
The name of SSTab is SSTab1.
I didn't use your new cbAddTab as i have another code to populate listbox so i used your old cbAddTab code. I even made new project and tried to use all your updated code but unfortunelty i get error in your updated code for cbAddTab too! The error :
Compile error:
Method or data memmber not found
pointing at :
.Visible = True
I used the following code commenting out the cbQuit part so now the application works well but only problem that i can't close any tabs!! If i keep that cbQuit part i keep getting
run-time error '438':
object doesn't support this property or method
pointing at this line:
.Container = SSTab1
I hope you help me fix the quit button so i be able to close tabs.
Code:
' in declarations
Public nnTABS As Integer
' the sub
Private Sub cbAddTab_Click()
With SSTab1
' 1. first time it is clicked - sets up the controls
If nnTABS = 0 Then
nnTABS = nnTABS + 1
.Visible = True
'.Top = 4500
'.Left = 5500
.Width = 2000
.Height = 5000
.Tabs = 1
.TabsPerRow = 10
.TabMaxWidth = 700
With WB1(0)
.Top = 500
.Left = 100
.Height = 4300
.Width = 5500
.Visible = True
.Navigate2 "cme.com"
End With
' 2 subsequent clicks -- adds new tab and browser instance
ElseIf nnTABS > 0 Then
nnTABS = nnTABS + 1
With SSTab1
.Tabs = nnTABS
.Tab = nnTABS - 1
End With
Load WB1(nnTABS - 1)
With WB1(nnTABS - 1)
.Container = SSTab1
.Top = 500
.Left = 100
.Height = 4300
.Width = 5500
.Visible = True
If nnTABS = 2 Then
.Navigate2 "yahoo.com"
ElseIf nnTABS = 3 Then
.Navigate2 "google.com"
ElseIf nnTABS = 4 Then
.Navigate2 "vbforums.com"
End If
End With
End If
End With
End Sub
Private Sub List1_Click()
'
' populate SSTab1, WB1(nnTABs)
'
With List2
If Option1.Value = True Then
v1 = List1.ListIndex
Else
v1 = List1.ListIndex
End If
v2 = .List(v1)
nnTABS = nnTABS + 1
' Tab
With SSTab1
.Tabs = nnTABS
.Tab = nnTABS - 1
If Option1.Value = True Then
.Caption = Left(v2, InStr(v2, ".") - 1)
Else
.Caption = List1.List(List1.ListIndex) & ":" & List1.ListIndex
End If
End With
' WB1
If nnTABS > 1 Then
Load WB1(nnTABS - 1)
End If
With Form1.WB1(nnTABS - 1)
.Container = SSTab1
'.Top = 1000
'.Left = 500
'.Height = 5500
'.Width = 9000
.Top = 1500
.Left = 100
.Height = 4300
.Width = 5500
.Visible = True
.StatusBar = True
.MenuBar = True
If Option1.Value = True Then
'MsgBox "wow"
.Navigate2 App.Path & "/" & "singers/" & v2
Else
.Navigate2 App.Path & "/" & v2
End If
End With
' cbQuit
If nnTABS > 1 Then
Load cbQuit(nnTABS - 1)
End If
'With cbQuit(nnTABS - 1)
' .Container = SSTab1
' .Top = 500
' .Left = 500
'.Height = 300
'.Width = 900
'.Visible = True
'End With
End With
End Sub
' 4. quit sub
Private Sub cbQuit_Click(Index As Integer)
'
' NOTE: only quits if on LAST tab
'
' last tab when only 1 tab
If nnTABS = 1 Then
nnTABS = 0
WB1(0).Visible = False
' last tab when >1 tabs
ElseIf nnTABS > 1 And Index = nnTABS - 1 Then
With WB1(nnTABS - 1)
.Stop
End With
If nnTABS > 1 Then
Unload WB1(nnTABS - 1)
Unload cbQuit(nnTABS - 1)
nnTABS = nnTABS - 1
With SSTab1
.Tabs = nnTABS
.Tab = nnTABS - 1
End With
End If
End If
End Sub
Re: How to make dynamic firefox type browser tabs ?
Tony
Now let me briefly deal with part 2 - your modifications.
I see one possible problem in the following code frag:
Code:
Private Sub List1_Click()
' ...
With Form1.WB1(nnTABS - 1) ' << this is the problem
.Container = SSTab1 ' << you get error here
The reason you get the error is that on the preceding statement,
you have changed the reference of WB1().
you have it as Form1.WB1(), which means you have Form1 as the
container. Hence, the subsequent statement is in conflict with this, and
you accordingly get the error.
WB1() should not be on the form, but rather on the SSTab control
This tells me that you have apparently modified the approach that I
tried to delineate in my prior post #12. Not that there is anything wrong
with that, but as you have now "branched out on your own", there
may be such unintended consequences.
Re: How to make dynamic firefox type browser tabs ?
Many Many thanks for your nice explanation. Unfortunetly i even couldn't run your demo project !! When i click the cbAddTab i get the following error again:
Compile error:
Method or data memmber not found
pointing at :
Quote:
.Visible = True
I copy and paste your exact code and placed all the controles as the way you explained but still i get the above error so i uploaded the demo project so you be able to look at it.
Regarding Part 2 my modification i changed With Form1.WB1(nnTABS - 1) to WB1(nnTABS - 1) and got this error now :
run-time error '438'
object doesn't support this property or method
pointing at in List1_Click :
With cbQuit(nnTABS - 1)
.Container = SSTab1 ===> pointing at here
part 2 - my modifications code.
Code:
Private Sub List1_Click()
'
' populate SSTab1, WB1(nnTABs)
'
With List2
If Option1.Value = True Then
v1 = List1.ListIndex
Else
v1 = List1.ListIndex
End If
v2 = .List(v1)
nnTABS = nnTABS + 1
' Tab
With SSTab1
.Tabs = nnTABS
.Tab = nnTABS - 1
If Option1.Value = True Then
.Caption = Left(v2, InStr(v2, ".") - 1)
Else
.Caption = List1.List(List1.ListIndex) & ":" & List1.ListIndex
End If
End With
' WB1
If nnTABS > 1 Then
Load WB1(nnTABS - 1)
End If
With WB1(nnTABS - 1)
.Container = SSTab1
'.Top = 1000
'.Left = 500
'.Height = 5500
'.Width = 9000
.Top = 1500
.Left = 100
.Height = 4300
.Width = 5500
.Visible = True
.StatusBar = True
.MenuBar = True
If Option1.Value = True Then
'MsgBox "wow"
.Navigate2 App.Path & "/" & "singers/" & v2
Else
.Navigate2 App.Path & "/" & v2
End If
End With
' cbQuit
If nnTABS > 1 Then
Load cbQuit(nnTABS - 1)
Load cbRefesh(nnTABS - 1)
End If
With cbQuit(nnTABS - 1)
.Container = SSTab1
.Top = 500
.Left = 500
.Height = 300
.Width = 900
.Visible = True
End With
End With
End Sub
Last edited by tony007; May 22nd, 2010 at 10:59 AM.
Re: How to make dynamic firefox type browser tabs ?
Q1 Answer : I have error in location 2
Q2 Answer :I have all those refrences checked but i got Microsoft word 9 object library instead of 11 and also i got Microsoft DAO 3.51 object library checked too
Q3 Answer: i coundn't find out what SP is installed but all i know it is Microsoft virsual basick 6 for 32 bit window development version 8176
Last edited by tony007; May 23rd, 2010 at 04:37 AM.