TabControl Articles and Tutorials

Adding Multi-Row Tabs

Author: Mike Palmatier
Platform: Visual C++ 6.0

The TabControl can display more than one row of tabs by using the SetLayout method to apply the xtpTabLayoutMultiRow flag. The number of rows is automatically set by the width and number of the tabs. The number of rows can change if the control is resized, which ensures that the tabs wrap to the next row. If the tab layout is not set to xtpTabLayoutMultiRow, and the last tab exceeds the width of the control, left and right arrow buttons are added at the right end of the TabControl.

// The TabControl can display more than one row of tabs
// by changing the Layout to xtpTabLayoutMultiRow.
m_wndTabControl.GetPaintManager()->SetLayout(xtpTabLayoutMultiRow);

article

The m_bMultiRowJustified property specifies the justification of the tabs in the TabControl. When True, each tab is wide enough to accommodate its caption and, if needed, the width of each tab is increased so that each row of tabs spans the width of the TabControl. This will stretch each row of tabs to fill the entire width of the TabControl.

If False, the tab rows will be non-justified. Each tab is just wide enough to accommodate its caption. The rows are not justified, so multiple rows of tabs are "jagged".

// The MultiRowJustified property specifies the
// justification of the tabs in the TabControl.
m_wndTabControl.GetPaintManager()->m_bMultiRowJustified = TRUE;

article

The m_bMultiRowFixedSelection property specifies whether the the row of the currently selected tab will be moved to the front of the tab rows. This determines how remaining rows of tabs in front of a selected tab are repositioned.

When False, the rows of tabs in front of the selected tab are repositioned at the opposite side (behind) of the control. For example, if there are three rows in the multi-row tab-control, and a tab in the second row is selected, all tab rows will be repositioned behind the second row.

When True, the rows in a multi-row tab control remain "fixed" when a tab is selected. The remaining rows of tabs in front of a selected tab will not be repositioned. For example, if there are three rows in the multi-row tab-control, and a tab in the second row is selected, the tab rows will remain the same.

// specifies whether the the row of the currently selected
// tab will be moved to the front of the tab rows.  This
// determines how remaining rows of tabs in front of a
// selected tab are repositioned.
m_wndTabControl.GetPaintManager()->m_bMultiRowFixedSelection = TRUE;