A Tab control looks something like a series of file folders, where you can see the "tabs" for all of them (unless they scroll out of view) but can see the contents of only one at a time. Another way to conceptualize a Tab control is as a combination of a Groupbox and a row of buttons ("tabs") along the top. Clicking on one of the buttons or tabs sends a keyboard command notification allowing the program to replace the contents of the current groupbox with new contents, depending on which tab was clicked.
The coordinates specified are for the outer rectangle, which includes the space occupied by the tabs. The "client area" of the tab control (the usable area bounded by the tabs at the top and the left, right and bottom edges) acts like a groupbox. Controls placed in this area must specify the ID of the tab control in the parentid parameter, and their coordinates are treated as offsets from the upper left corner of this client area. If the number and style of tabs is such that there are multiple rows of tabs, the client area is further reduced by the space taken up the extra row(s) of tabs, so you should allow extra space if this is a possibility.
As with a groupbox, deleting the tab control deletes all of the controls within it. Perhaps more importantly, using opcode CTLOP_CLR to clear the tab deletes all the controls on the current tab page, a necessary step in switching to a new tab page.
Variations of the basic tab control can be specified by adding one or more of the following to the winstyle parameter:
Symbol |
Value |
Description |
TCS_FLATBUTTONS |
&h0008 |
|
TCS_FORCELABELLEFT |
&h0020 |
Tab labels are left justified within each tab. This only makes sense with the TCS_FIXEDWIDTH style. Otherwise they are centered. |
TCS_BUTTONS |
&h0100 |
Tabs appear as buttons and no border is drawn around the display area. |
TCS_MULTILINE |
&h0200 |
If the tabs do not fit on one row, multiple rows are used. Otherwise, a scroll button is placed at the edge of the one row of tabs to allow it to be scrolled horizontally. |
TCS_FIXEDWIDTH |
&h0400 |
All tabs are made the same width; otherwise the width of each tab is based on the text in that tab. |
The tabs are defined by specifying ctext in the following format:
CTEXT=Label1~Cmd1~~Label2~Cmd2~~...LabelN~CmdN
In the above specification, Label1 through LabelN represent the text strings displayed in each tab, and Cmd1 through CmdN represent the keyboard command strings each tab sends. As an example:
CTEXT="&Receivables~" + chr(7) + chr(250) + "101." + "~~&Payables~" + chr(7) + chr(250) + "102." + "~~General &Ledger~" + chr(7) + chr(250) + "103."
This would define a set of 3 tabs, "Receivables", "Payables" and "General Ledger" (with corresponding Accelerator keys R, P, and L). Clicking on the "Receivables" tab (or keying alt+R) would generate exitcode –101 (pseudo function key F101), etc. A program using this arrangement would have to check for these exitcodes (or raw key sequences if your input routine did not provide automatic exitcode conversions), and on receipt, display the appropriate options within the display area of the tab control, according to which tab clicked.
See Also
• TabX Control for an extended version of the Tab control.