October 24, 2016
Hot Topics:

Auto Property Sheet in FormView

  • December 11, 1999
  • By Rick Shide
  • Send Email »
  • More Articles »

This article was contributed by Richard Shide.

This project provides derived MFC classes for painlessly implementing Property Sheets in a CFormViews.  This implementation puts the Property Sheet at the bottom of the view as shown in the following image:

wpe1.jpg (14545 bytes)

Four derived MFC classes are used in this implementation.

  • CPropPgFormView: a CFormView derived class.
  • CPropPgFormDoc: a CDocument derived class.
  • CViewPropertyPage: a CPropertyPage derived class.
  • CViewPropertySheet: a CPropertySheet derived class.

The property sheet is managed by CPropPgFormView, moving the sheet below the template-based controls of the CFormView derived class.  Resizing the frame resizes the Property Sheet accordingly.

What CPropPgFormView gives you:

  • Scrolling sizes are managed for you.
  • Tab order is enabled across the CFormView controls and the Property Sheet.
  • Hotkeys work for the page tabs.
  • Page changing can be disabled.
  • Property page controls can be disabled.
  • Auto-centering of controls within each property page.
  • Adjustable distance between the bottom-most template-based control and the Property Sheet.
  • Form notification of page activation

To use these classes, follow these steps:

  • Base your property pages on CViewPropertyPage instead of CPropertyPage.
  • Base your form view class from CPropPgFormView instead of CFormView.
  • Register the document template with the correct classes in your apps InitInstance():
        CMultiDocTemplate* pDocTemplate;
        pDocTemplate = new CMultiDocTemplate(
            RUNTIME_CLASS(CMyFormView));      // your CPropPgFormView class
  • Add the property pages in your view's Create() and create the sheet:.
    BOOL CMyFormView::Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName,
      DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, CCreateContext* pContext)
    if (!CPropPgFormView::Create(lpszClassName, lpszWindowName,
       dwStyle, rect, pParentWnd, nID, pContext))
    return FALSE;


    // create a modeless property sheet
    if (!m_PropSheet.Create(this)) {
    return FALSE;

    return TRUE;

... and that's it.


Methods and members:

void ResizeForNewControl() - resizes the Property Sheets after programmatically adding new controls
void SetPropertySheetOffset(int iOffset  = PS_Y_OFFSET, BOOL bRedraw  = FALSE) - sets distance between bottom-most form control and top of the Property Sheet
void ResizeParentFrame() - resizes frame window to most efficiently encompass all controls and Property Sheet, and sets scroll sizes
CViewPropertySheet    m_PropSheet - the Property Sheet

BOOL Create(CWnd *pParentWnd, DWORD dwStyle, DWORD dwExStyle) - creates the Property Sheet
void CenterControls(BOOL bCenter /* = TRUE */) - centers the controls on all pages
virtual void AllowPageChange(BOOL bAllowPageChange = TRUE) - allow/disallow changing to a different page

void EnableControls(BOOL bEnable) - enable/disable all controls on a page


In addition, the WM_NOTIFY TCN_SELCHANGE  page change notification message is reflected to the derived CPropPgFormView window.

Please look at the provided project for a better understanding of the implementation details.


Download demo project - 39 Kb


Date Posted: December 11, 1999

Comment and Contribute


(Maximum characters: 1200). You have characters left.



Enterprise Development Update

Don't miss an article. Subscribe to our newsletter below.

Sitemap | Contact Us

Thanks for your registration, follow us on our social networks to keep up-to-date
Rocket Fuel