Creates an Ocx TabStrip control in the current active form, window, or dialog.
Ocx TabStrip name [= text$] [, id%] [, x, y, w, h] [, style%]
text$:control text
id%:control identifier
x, y, w, h:iexp
style%:the control styles
A TabStrip control is like the dividers in a notebook or the labels on a group of file folders. By using a TabStrip control, you can define multiple pages for the same area of a window or dialog box in your application.
The control consists of one or more Tab objects in a Tabs collection. At run time, you can affect the Tab object's appearance by setting properties. You can also add and remove Tab objects at run time using methods.
The Style property determines whether the TabStrip control looks like push buttons (Buttons or Flat-Buttons) or notebook tabs (Tabs). At design time when you put a TabStrip control on a form, it has two notebook tabs. If the Style property is set to tabTabs, then there will be a border around the TabStrip control's internal area. When the Style property is set to tabButtons, no border is displayed around the internal area of the control, however, that area still exists.
To set the overall size of the TabStrip control, use its drag handles and/or set the Top, Left, Height, and Width properties. Based on the control's overall size at run time, GFABASIC automatically determines the size and position of the internal area and returns the Client-coordinate properties - ClientLeft, ClientTop, ClientHeight, and ClientWidth. The MultiRow property determines whether the control can have more than one row of tabs, the TabWidthStyle property determines the appearance of each row, and, if TabWidthStyle is set to tabFixed, you can use the TabFixedHeight and TabFixedWidth properties to set the same height and width for all tabs in the TabStrip control.
To contain the actual pages and their objects, you must use Frame, Form, or Image controls that match the size of the internal area which is shared by all Tab objects in the control. When Frame is used as a container (OcxOcx tbs Frame frm), it has the additional feature that BorderStyle = 0 and Transparent = 0. The coordinates specified in the OcxOcx command are ignored; the container is automatically sized to the TabStrip client coordinates.
The Text/Caption property of the Frame and Form is used as the title for the Tab. The Image control doesn't have a Caption property, and is less useful.
The TabStrip Ocx control has the following properties, methods, and events.
Appearance | BackColor | ClientHeight | ClientLeft | ClientTop | ClientWidth | Enabled | Font | FontBold | FontItalic | FontStrikethru | FontUnderline | FontName | FontSize | HotTracking | Height | HelpContextID | hWnd | ImageList | Index | Left | MouseCursor | MouseIcon | MousePointer | MultiRow | Name | Parent | Placement | ScrollOpposite | SelectedIndex | SelectedItem | Separators | Style | Tab | TabCount | TabFixedHeight | TabFixedWidth | TabMinWidth | Tabs | TabStop | TabWidthStyle | Tag | Top | Visible | WhatsThisHelpID | Width
The TabCount property returns the number of tabs. Short for .Tabs.Count.
Add | AddItem | Clear | HitTest | Item | Move | NextTab | PrevTab | Refresh | Remove | SetFocus | SetFont | TextHeight | TextWidth | ZOrder
BeforeChange | Change | Click | KeyDown, KeyUp | KeyPress | MouseDown | MouseUp | MouseMove
Const USE_ADD = 1
Form Hidden Center frm1 = "TabStrip", , , 400, 300
Ocx TabStrip tbs = , 20, 20, ScaleWidth - 40, ScaleHeight - 40
tbs.HotTracking = True
tbs.Placement = 1
If USE_ADD
Ocx Frame fr1 = "Tab #1"
Ocx Frame fr2 = "Tab #2"
Ocx Frame fr3 = "Tab #3"
Ocx Frame fr4 = "Tab #4"
Else
' See Remarks
OcxOcx tbs Frame fr1 = "Tab #1"
OcxOcx tbs Frame fr2 = "Tab #2"
OcxOcx tbs Frame fr3 = "Tab #3"
OcxOcx tbs Frame fr4 = "Tab #4"
EndIf
OcxOcx fr1 Option opt1 = "Option #1", 20, 20, 80, 24
OcxOcx fr1 Option opt2 = "Option #2", 20, 50, 80, 24
OcxOcx fr2 CheckBox chk1 = "Check #1", 20, 20, 80, 24
OcxOcx fr2 CheckBox chk2 = "Check #2", 20, 50, 80, 24
OcxOcx fr3 TextBox txt1 = "TextBox #1", 20, 20, 280, 40
OcxOcx fr3 TextBox txt2 = "TextBox #2", 20, 130, 280, 40
OcxOcx fr4 Command cmd1 = "NextTab", 90, 20, 80, 24
OcxOcx fr4 Command cmd2 = "PrevTab", 90, 50, 80, 24
If USE_ADD
Dim tab As Tab
tbs.Tabs.Add 1, , fr1.Caption , , fr1
tbs.AddItem 2, , fr2.Caption, , fr2
tbs.Add 3, , fr3.Caption, , fr3
Set tab = tbs.AddItem(4, , , , fr4)
tab.Caption = fr4.Caption
EndIf
' Creates ragged rows of tabs.
tbs.MultiRow = True
tbs.TabWidthStyle = tabNonJustified
frm1.Show
tbs(2).Selected = True
Do
Sleep
Until Me Is Nothing
Sub tbs_Change
Switch tbs.SelectedIndex
Case 1 : opt1.SetFocus
Case 2 : chk1.SetFocus
Case 3 : txt1.SetFocus
Case 4 : cmd1.SetFocus
EndSwitch
End Sub
Sub tbs_BeforeChange(Cancel?)
If MsgBox("Tab change allowed?", MB_OKCANCEL) = IDCANCEL
Cancel? = True
EndIf
Sub cmd1_Click
tbs.NextTab
Sub cmd2_Click
tbs.PrevTab
When using the OcxOcx command to associate a container with a TabStrip control, the Add[Item] method is invoked implicitly. Also, the caption of the container is used for the Tab object Text.
A third way of creating TabStrip containers is by using the Form Editor. First create a Form with a TabStrip and then create a set of Forms that define the contents of each tab. Then in code:
LoadForm frmTabStrip Hidden
Do
Sleep
Until Me Is Nothing
Sub frmTabStrip_Load
LoadForm frm2 Hidden
LoadForm frm3 Hidden
LoadForm frm4 Hidden
LoadForm frm5 Hidden
tbs1.AddItem , , "GFA" , , frm2
tbs1.AddItem , , "Software", , frm3
tbs1.AddItem , , "Technologies", , frm4
tbs1.AddItem , , "GmbH", , frm5
frmTabStrip.Show
EndSub
Sub tbs1_Change
Switch tbs1.SelectedIndex
Case 1 : chk2.SetFocus
Case 2 : cmd2.SetFocus
Case 3 : ed1.SetFocus
Case 4 : cmd5.SetFocus
EndSwitch
End Sub
Animation, CheckBox, ComboBox, Command, CommDlg, Form, Frame, Image, ImageList, Label, ListBox, ListView, MonthView, Option, ProgressBar, RichEdit, Scroll, Slider, StatusBar, TextBox, Timer, TrayIcon, TreeView, UpDown
{Created by Sjouke Hamstra; Last updated: 17/02/2022 by James Gaite}