Share via


Tabs and Tab Control Attributes

OverviewSample

You have considerable control over the appearance and behavior of tabs that make up a tab control (). 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 , modify the TCITEM structure (specifically the dwState and dwStateMask data members), and then return the modified TCITEM structure with a call to . If you need to clear the item states of all the tab items in a CTabCtrl object, make a call to . 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;

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 in the Platform SDK. For more information about adding tabs to a tab control, see Adding Tabs to a Tab Control later in this article.

See Also   Windows Common Controls and MFC Classes