BBjWindow::addTabCtrl

Description

Adds a tab control in the BBjWindow of the current context.

Syntax

Return Value

Method

BBjTabCtrl addTabCtrl()
BBjTabCtrl addTabCtrl(int ID)
BBjTabCtrl

addTabCtrl(int ID, number x, number y, number w, number h)

BBjTabCtrl

addTabCtrl(int ID, number x, number y, number w, number h, string flags)

BBjTabCtrl

addTabCtrl(int ID, number x, number y, number w, number h, string flags, string styles)

BBjTabCtrl

addTabCtrl(int ID, number x, number y, number w, number h, string flags, string styles, string tabDesc)

BBjTabCtrl

addTabCtrl(int ID, number x, number y, number w, number h, string flags, string styles, string tabDesc, int imageList)

BBjTabCtrl addTabCtrl(int ID, string flags)
BBjTabCtrl addTabCtrl(int ID, string flags, string styles)
BBjTabCtrl addTabCtrl(int ID, string flags, string styles, string tabDesc)
BBjTabCtrl addTabCtrl(int ID, string flags, string styles, string tabDesc, int imageList)
BBjTabCtrl addTabCtrl(string flags)
BBjTabCtrl addTabCtrl(string flags, string styles)
BBjTabCtrl addTabCtrl(string flags, string styles, string tabDesc)
BBjTabCtrl

addTabCtrl(string flags, string styles, string tabDesc, int imageList)

Parameters

Variable

Description

ID

Control ID number. It must be an integer between 1 and 32767 and be unique within a given top-level window.

x

Horizontal position of the upper-left corner of the tab control.

y

Vertical position of the upper-left corner of the tab control.

w

Width of the tab control.

h

Height of the tab control.

flags

Tab control flags, as follows:

Flag Description
$0001$ Sets the control to be initially disabled.
$0002$ In BBj 16.0 and higher, sets the tab control to initially closeable (setCloseable).
$0010$ Sets the control to be initially invisible.
$0800$ Draws a recessed client edge around the control.
$1000$ Draws a raised edge around the control.

styles

Tab style flags, as follows:

Flag Description
$00000001$ Displays tabs as buttons but does not draw a border around the display area.
$00000002$ Adjusts all tabs to the same width but cannot be combined with $00000100$.
$00000004$ Prevents the tab control from receiving input focus.
$00000008$ Sets tabs to receive focus when clicked.
$00000010$ Forces icons to the left margin and must be used with $00000002$.
$00000020$ Sets the label immediately to the right of the icon instead of centering it. Must be used with $00000002$ and includes $00000010$.
$00000040$ Allows multiple tab rows.
$00000080$ Does not extend each row of tabs to fill the entire width of the control. This is the default style.
$00000100$ Extends the width of each tab to fill the entire width of the tab control and is ignored, unless $00000040$ is also specified.
$00000200$ Retains the image list when the control is destroyed to allow it to be assigned to multiple tab controls.
$00000400$ Causes all tabs to appear on one line. Use scroll to see more tabs, if necessary. This is the default line style.
$00000800$ Displays tabs and draws a border around the display area. This is the default style.
$00001000$ Prevents a tab's associated control or child window from being automatically displayed when the tab is selected. It also prevents a tab's managed controls or child windows from being automatically resized when the tab is resized. By default, a tab will automatically display an associated control or child window when it is selected and will automatically resize its managed controls or child windows when it is resized.
tabDesc

Tab descriptor. A tab descriptor must exist for each tab item on the tab control and must reference the index of the image to be displayed on the tab. The table below identifies the tab descriptor fields. The string is identical to the TABDES$ string defined in SENDMSG() TABCTRL Function 27:

imgidx:i(2),id:I(2),text:c(1*=0)

The imgidx field is a binary string that contains the index of the image list being used by the tab control. It has a relative offset of 1 and a length of 2. A value of -1, $FFFF$, indicates that the image is to be displayed on the tab. If no image list is specified during creation, this field is ignored.

The id field is a binary string containing the ID of the child window or control to be displayed when the user selects the tab item. It has a relative offset of 3 and a length of 2. A value of -1, $FFFF$, indicates that no child window or control will automatically be displayed. The control or child window does not need to exist at the time of creation, but it must exist when user selects the tab, or a blank client area will be shown.

The text field is a null-terminated string that defines the text to be displayed on the tab item. It has a relative offset of 5 and a variable length.

imageList

Imagelist ID. If the specified bitmap cannot be located, an !ERROR=12 is generated.

Return Value

Returns the created BBjTabCtrl object.

Remarks

The tab control client area displays the contents of a control or child window when a tab is selected.

The tabDesc variable may not contain special characters. These are characters with ASCII representations higher than 127, such as the € character. If special characters are needed in the tab descriptions, then use the BBjTabCtrl.addTab(Title) to set the title of specific tabs.

If the ID parameter is not specified, a control ID is assigned dynamically using getAvailableControlID().

If the x, y, width, and height parameters are not specified, they are all initialized to 0. This is typically for use with DWC windows that dynamically arrange their contents (window creation flag $00100000$).

Example

rem ' BBjTabCtrl

sysgui = unt
open (sysgui)"X0"
sysgui! = bbjapi().getSysGui()
window! = sysgui!.addWindow(100,100,400,300,"BBjTabCtrl",$00090003$)
window!.setCallback(window!.ON_CLOSE,"eoj")
tabctrl! = window!.addTabCtrl(101,25,25,350,200)
tabctrl!.setCallback(tabctrl!.ON_TAB_SELECT,"select")
tabctrl!.setCallback(tabctrl!.ON_TAB_CLOSE,"close")
for i = 1 to 4
    child! = window!.addChildWindow(200+I,50,50,200,100,"",$00000800$,I,$$)
    text$ = "Child Window " + str(I)
    text! = child!.addStaticText(300+I,i*10,i*10,150,25,text$)
    title$ = "Tab " + str(I)
    tabctrl!.addTab(title$,child!)
next i
closeable! = window!.addCheckBox(102,25,250,150,25,"setCloseable",$$)
closeable!.setCallback(closeable!.ON_CHECK_ON,"setCloseable1")
closeable!.setCallback(closeable!.ON_CHECK_OFF,"setCloseable0")
closeableAt! = window!.addCheckBox(103,200,250,150,25,"setCloseableAt",$$)
closeableAt!.setCallback(closeable!.ON_CHECK_ON,"setCloseableAt1")
closeableAt!.setCallback(closeable!.ON_CHECK_OFF,"setCloseableAt0")
process_events

eoj:
release

select:
    event! = sysgui!.getLastEvent()
    index = event!.getIndex()
    title$ = event!.getTitle()
    print "Selected index",index,": ",title$
    closeableAt!.setSelected(tabctrl!.isCloseableAt(index))
    closeableAt!.setText("setClosebleAt "+str(index))
return

setCloseable0:
    tabctrl!.setCloseable(0)
return

setCloseable1:
    tabctrl!.setCloseable(1)
return

setCloseableAt0:
    tabctrl!.setCloseableAt(tabctrl!.getSelectedIndex(),0)
return

setCloseableAt1:
    tabctrl!.setCloseableAt(tabctrl!.getSelectedIndex(),1)
return

close:
    event! = sysgui!.getLastEvent()
    index = event!.getIndex()
    title$ = event!.getTitle()
    query$ = "Close tab #"+str(index)+" ("""+title$+""")?"
    if (msgbox(query$,4+32+256,"ON_TAB_CLOSE") = 6) then
        tabctrl!.removeTab(index)
    endif
return

See Also

BBjAPI

BBjSysGui

BBjControl

BBjTabCtrl

BBjWindow

'TABCTRL' Mnemonic

See the BBj Object Diagram for an illustration of the relationship between BBj Objects.