Microsoft KB Archive/131992

= HOWTO: How to Create a Property Sheet That Has Scrolling Tabs in MFC =

Article ID: 131992

Article Last Modified on 11/21/2006

-

APPLIES TO

 Microsoft Foundation Class Library 4.2, when used with:  Microsoft Visual C++ 1.52 Professional Edition

 Microsoft Visual C++ 2.0 Professional Edition

 Microsoft Visual C++ 2.1

 Microsoft Visual C++ 4.0 Standard Edition</li></ul> </li></ul>

-

<div class="notice_section">

This article was previously published under Q131992

<div class="summary_section">

SUMMARY
This article explains how to create a property sheet (tabbed dialog box) that uses a scrolling-tabs style instead of the default stacked-tabs style.

<div class="moreinformation_section">

MORE INFORMATION
A property sheet is created using the CPropertySheet class. This class uses an internal class (CTabControl) to manage the actual tabs appearing along the top of the property sheet. When there are more tabs than will fit across a single row, the default behavior is to display the tabs stacked in multiple rows.

In an application where this will cause layout problems or where screen space is at a premium, a scrolling-tab style may be preferred. The CTabControl can show its tabs in a single row with small scroll arrows on the ends. When a user clicks the arrows, the tabs which were not visible are scrolled into view. The CPropertySheet class uses its m_bStacked member variable to determine which style to use when creating the CTabControl. If it is set to TRUE (the default), the tabs are created stacked; when FALSE, the scrolling tab style is used. You can use the inline member function EnableStackedTabs to set the value of m_bStacked.

The simplest approach is to call EnableStackedTabs(FALSE) on the property sheet variable just before calling DoModal or Create on it. This requires that you call the EnableStackedTabs function whenever you create a modal or a modeless property sheet. To incorporate this style in a CPropertySheet derived class, you need to write a message handler for WM_CREATE. In the overridden version of OnCreate, call EnableStackedTabs(FALSE) before calling the base class implementation: int CMyPropertySheet::OnCreate(LPCREATESTRUCT lpCreateStruct) {     // Set for Scrolling Tabs style EnableStackedTabs(FALSE);

// Call the base class if (CPropertySheet::OnCreate(lpCreateStruct) == -1) return -1;

// TODO: Add your specialized creation code here

return 0; } Be aware that CPropertySheet::EnableStackedTabs is declared in the "Implementation" portion of the CPropertySheet class declaration (for Visual C++ version 4.0, see AFXDLGS.H). It is entirely likely that this function will change with the next release of MFC. If at all possible, do not design your MFC application to depend upon any object's methods or data that are declared with an Implementation section.

<div class="references_section">