Tab control windows

A tab control window is one in which each child window defines a tab, as illustrated in this example:


Tab One, Tab Two and Tab Three are the titles of the three child windows. Only one child window is shown at any time; the user selects a window by clicking on the tab. The previously displayed window is automatically hidden. The controls contained in each child window become visible when the window tab is selected. Tab child windows may be given a hotkey - see Window title.

A window is defined as a tab control window if it has the style WS_TABCONTROL. The size and positioning of this window determines the location and dimensions of the tab control. A tab control window must have a parent window; in the example above the parent is the task window wintask. The parent window can contain other controls; the tab control window itself can contain only child windows.

The only properties it is necessary to specify for a tab control window are the position, size, parent and style.

Apart from WS_TABCONTROL, the only style flags relevant to a tab control window are:


This flag causes all the tabs in the window to be of the same width, regardless of the length of the text that appears on the tab. All tabs are extended to match the widest.


If this is defined, then if the total width of the tabs means that they cannot be fitted on a single line, multiple lines of tabs are created. This reduces the area available for controls. If this flag is not defined, scroll arrows are provided to move the tab display left and right.


Left justifies the labels on the tabs (the default is to centre them.) This flag is ignored unless WS_FIXEDWIDTH is also specified.


If the total width of the tabs is less than the tab control window width, this flag right justifies the tabs in the tab control window. The default is for them to be left-justified.

If a tab control window has the option OPT_NOCOLOURED, the default background colour is used for the tabs of its child windows. If this option flag is absent, the child window background colour is used.

Tab control child windows

Each child window must contain a parent = clause allocating it to the tab control window.

The x co-ordinate value in each child window’s definition determines the position of its tab, with the lowest numbered tab appearing at the left, and so on. A window defined as:

+window Tab1 at 1, 0 {

would appear at the far left. The y co-ordinate is ignored for the children of tab control windows, and should always be coded as 0 to ensure compatibility with any future enhancements.

Values should be specified for max_width and max_height. These will normally be the same values as those assigned to the tab control window.

The title of the window is the text that appears on the tab. The width of the text determines the width of the tab.

The appearance of a tab control window is fixed.

The font for the tabs is the data font of the tab control window.

When the user clicks on the tab, the event EV_SELECT_TAB is sent to the window.

The use of the following commands with tab control child windows should be noted:

show window_id

Brings the window to the front, automatically closing the previously displayed child window.

hide window_id

Has no effect unless the window stated is currently selected, in which case it is hidden, leaving no child window visible.

destroy window_id

Removes the tab.

create window_id

Adds the tab.

The program $SCULPTOR/demo/controls/tabs.f demonstrates tab control windows.