Share via


Tabs and Tab Control Attributes

You have considerable control over the appearance and behavior of tabs that make up a tab control (CTabCtrl). Each tab can have a label, an icon, an item state, and an application-defined 32-bit value associated with it. For each tab, you can display the icon, the label, or both.

In addition, each tab item can have three possible states: pressed, unpressed, or highlighted. This state can only be set by modifying an existing tab item. To modify an existing tab item, retrieve it with a call to GetItem, modify the TCITEM structure (specifically the dwState and dwStateMask data members), and then return the modified TCITEM structure with a call to SetItem. If you need to clear the item states of all the tab items in a CTabCtrl object, make a call to DeselectAll. This function resets the state of all tab items or all items except the one currently selected.

The following code clears the state of all tab items and then modifies the state of the third item:

//modify the third item to be highlighted
TCITEM curItem = {0};

m_TabCtrl.DeselectAll(FALSE); //reset all tab items
curItem.mask = TCIF_STATE;
m_TabCtrl.GetItem(2, &curItem);
curItem.mask = TCIF_STATE;
curItem.dwState = TCIS_HIGHLIGHTED;
curItem.dwStateMask = TCIS_HIGHLIGHTED;
m_TabCtrl.SetItem(2, &curItem);

For more information about tab attributes, see Tabs and Tab Attributes in the Windows SDK. For more information about adding tabs to a tab control, see Adding Tabs to a Tab Control later in this topic.

See Also

Reference

Using CTabCtrl

Concepts

Controls (MFC)