|
-
Oct 18th, 2002, 03:19 PM
#1
Thread Starter
Fanatic Member
TabStrip Tabs at run time
Is it possible to create tabs in a TabStrip control at runtime. If so, how would you code them? Thanks, Jeremy
-
Oct 18th, 2002, 03:21 PM
#2
PowerPoster
The tabstrip control that is by itself, or the tabstrip control within the Windows Common Controls?
-
Oct 18th, 2002, 03:25 PM
#3
PowerPoster
VB Code:
For i = 1 To 10
TabStrip1.Tabs.Add , , "Tab #" & i
Next
That will add 10 tabs to the tabstrip control, but I don't know how to add them to hte MS Tabbed Dialog control (SSTab).
-
Oct 18th, 2002, 03:26 PM
#4
Thread Starter
Fanatic Member
What I need
For each item in my product structure, represented by a treeview, I need to have a tab in my TabStrip. Also, this Product Structure treeview is capable of having new nodes created by drag and drop so when a new node is created, I need a new tab. As far as the tab pages go, I need to have a windows control on each one. Got any ideas. This is my first tabstrip and I'm trying to mimic something I wrote in VBA for excel. Thanks, Jeremy
-
Oct 18th, 2002, 03:27 PM
#5
Thread Starter
Fanatic Member
No SST
I'm not using SST. Just FYI.
-
Oct 18th, 2002, 03:33 PM
#6
PowerPoster
Whenever you need a new tab, just call the TabStrip.Tabs.Add command to add one, and TabStrip.Tabs.Remove to remove tabs you no longer need.
-
Oct 18th, 2002, 03:40 PM
#7
Thread Starter
Fanatic Member
Ok
Ok, I know how to add and remove now but how do I add controls to the tabs? Also, how do I reference information on each tab? I mean, is each tab treated as it's own? You gotta remember, I don't know tabs too well. I'm a dumby to tabs right now. I need to know how to add a tab, reference information on that tab. Make sense? Thanks for your help, Jeremy
-
Oct 18th, 2002, 03:42 PM
#8
PowerPoster
You can't add controls to the tabs. They don't act as frames, the way th SSTab control does. You will have to add a frame for each tab and draw your controls inside that frame. If you are loading them at runtime, you will need to load them, then set their parent to the frame control using the SetParent API call.
-
Oct 18th, 2002, 03:48 PM
#9
PowerPoster
but I don't know how to add them to hte MS Tabbed Dialog control (SSTab).
SSTab1.Tabs = 10
SSTab1.TabsPerRow = 10
-
Oct 18th, 2002, 03:58 PM
#10
Thread Starter
Fanatic Member
I'm lost.
You lost me. I don't understand.
-
Oct 18th, 2002, 04:04 PM
#11
Thread Starter
Fanatic Member
I know, I'm dumb
Last reply wasn't too informative. How can I "draw" a control at runtime? Also, I don't understand Frames either. I know that it doesn't make it any easier for you to help but I need to have some of this explained. Thanks for your help, Jeremy
-
Oct 18th, 2002, 04:13 PM
#12
PowerPoster
You have to load controls, not draw them at run time. If you don't know how to do that, then why are you asking how to associate them with tabs when you don't even know how to load them first?
Say you have a frame in a control array named TabFrame(0) and a Tabstrip called TStrip and a textbox in a control array named txtData(0).
VB Code:
Private Declare Function SetParent Lib "user32" Alias "SetParent" (ByVal hWndChild As Long, ByVal hWndNewParent As Long) As Long
Dim i As Integer
i = i + 1
Load TabFrame(i)
Load txtData(i)
Tabstrip.Tabs.Add , , "Tab #" & i
TabFrame(i).Visible = True
SetParent txtData(i).hWnd, TabFrame(i).hWnd
txtData(i).Visible = True
You will need more code to make that work, but that is the basics of loading new controls onto the form that are in an array and then setting them inside frame controls. This way when you click the tabs, you can use a select statement in the tab strip's click event to set a certain frame on the form to visible and set every other frame to invisible... very tricky to explain and that's the best I can do.
-
Oct 18th, 2002, 04:18 PM
#13
Thread Starter
Fanatic Member
Thanks
Thanks for your help.
-
Oct 18th, 2002, 04:24 PM
#14
PowerPoster
SetParent isn't necessary to use. Most of controls have Container property.
-
Oct 18th, 2002, 05:29 PM
#15
PowerPoster
Can you set the container property though? Like Text1.Container = Frame1? I have never tried it like that, I always use SetParent.
-
Oct 18th, 2002, 09:13 PM
#16
PowerPoster
Oh, sure - that's what this property is for:
VB Code:
Private Sub Command1_Click()
'the following line will set new parent container for a Texbox
Set Text1.Container = Frame1
Text1.Move 120, 240
End Sub
-
Oct 18th, 2002, 10:40 PM
#17
PowerPoster
Originally posted by IROY55
Oh, sure - that's what this property is for:
VB Code:
Private Sub Command1_Click()
'the following line will set new parent container for a Texbox
Set Text1.Container = Frame1
Text1.Move 120, 240
End Sub
Have you tried that? Gave me an error. Oh wait... ahhhh! The elusive Set statement... I never use set, lol, so I didn't think to use it here. Very good observation IROY
-
Oct 18th, 2002, 11:28 PM
#18
Lively Member
insert a new tabstrip (from ms common controls, not sstab). make sure it has just one tab. below the tabstrip, make a button. in the tab sheet, make a new frame and set its Index property to 0. in the frame, make a new button and set its index prop to 0.
now use this code:
Private Declare Function SetParent Lib "user32" (ByVal hWndChild As Long, ByVal hWndNewParent As Long) As Long
Private Sub Command1_Click()
TabStrip1.Tabs.Add , , TabStrip1.Tabs(1).Caption
Load Frame1(Frame1.Count)
With Frame1(Frame1.Count - 1)
.Caption = Frame1.Count
.ZOrder 0
End With
tabHwnd = ObjPtr(TabStrip1.Tabs(TabStrip1.Tabs.Count))
frameHwnd = Frame1(Frame1.Count - 1).hWnd
Load Command2(Command2.Count)
With Command2(Command2.Count - 1)
.Visible = True
.Caption = Command2.Count
End With
SetParent Command2(Command2.Count - 1).hWnd, frameHwnd
End Sub
Private Sub TabStrip1_Click()
currIndex = TabStrip1.SelectedItem.Index - 1
For x = 0 To Frame1.Count - 1
If x <> currIndex Then Frame1(x).Visible = False
Next
Frame1(currIndex).Visible = True
End Sub
-
Oct 19th, 2002, 07:05 AM
#19
PowerPoster
KrazyGamer,
as I already pointed out most of controls have Container Property, therefore use of SetParent function is overhead.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|