You create a tab control by specifying WC_TABCONTROL in the lpClassName parameter to the CreateWindowEx function. Windows CE registers this class when it loads the common control DLL. You can use the InitCommonControls function to ensure that this DLL is loaded. To register the tab control class using the InitCommonControlsEx function, specify the ICC_ TAB_CLASSES flag as the dwICC member of the INITCOMMONCONTROLSEX structure you pass in the lpInitCtrls parameter.
To add tabs to a tab control, use the TCM_INSERTITEM message, which specifies the position of the tab and the address of its TCITEM structure. You can retrieve and set the contents of an existing tab by using the TCM_GETITEM and TCM_SETITEM messages. For each tab, you can specify an icon, a label, or both. You can also specify application-defined data to associate with the tab.
Other messages that you can use with a tab control are described in the following table.
Message | Description |
---|---|
TCM_GETITEMCOUNT | Retrieves the current number of tabs. |
TCM_DELETEITEM | Deletes a tab. |
TC_DELETEALLITEMS | Deletes all tabs in a tab control. |
You can associate application-defined data with each tab. For example, you might save information about each page with its corresponding tab. By default, a tab control allocates four extra bytes per tab for application-defined data. You can change the number of extra bytes per tab by using the TCM_SETITEMEXTRA message. You can only use this message when the tab control is empty.
The lParam member of the TCITEM structure specifies application-defined data. If you use more than four bytes of application-defined data, you need to define your own structure and use it instead of TCITEM. You can retrieve and set application-defined data the same way you retrieve and set other information about a tab: Use the TCM_GETITEM and TCM_SETITEM messages.
Note Windows CE does not support vertical text. If you create vertical tabs, and want to use vertical text, you have to create a text bitmap and rotate it. Then, you can add the bitmap to an image list and attach it to the tab by specifying its image list index in the iImage member of the TCITEM or TCITEMHEADER structure.