Auto Property Sheet in FormView

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(
            IDR_SHEETITYPE,
            RUNTIME_CLASS(CPropPgFormDoc),
            RUNTIME_CLASS(CChildFrame),
            RUNTIME_CLASS(CMyFormView));     
    // your CPropPgFormView class
        AddDocTemplate(pDocTemplate);
  • 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;

    m_PropSheet.AddPage(&m_Page1);
    m_PropSheet.AddPage(&m_Page2);
    m_PropSheet.AddPage(&m_Page3);

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

    return TRUE;
    }

... and that's it.

 

Methods and members:

CPropPgFormView
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

CViewPropertySheet
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


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

CPropPgFormDoc
Nothing

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.

Downloads

Download demo project - 39 Kb


Comments

  • Thank you very much, it is very usefull for me to learn MFC

    Posted by buidinhba5 on 08/27/2008 12:26am

    Thank you very much, it is very usefull for me to learn MFC

    Reply
  • Add ctrls by hand

    Posted by Legacy on 09/23/2003 12:00am

    Originally posted by: Angel Cervantes R.

    Hi, PLEASE!! Can you tell me how can I add controls by hand (with Create function) in the Property Page?

    Reply
  • Adding large number of records in sorted combobox

    Posted by Legacy on 06/21/2002 12:00am

    Originally posted by: Puneet Jain

    I am finding difficult in initializing the combobox with large number of records and then sorting it.
    Every time, a function is called, its takes a long time to read the records and sort them.
    Is there any way, where after the first use, the process takes a very short time after every reuse.
    I am using VC++ as my application.

    Thanks
    -Puneet

    Reply
  • To change the Look of Property page to Excel sheet type

    Posted by Legacy on 05/06/2002 12:00am

    Originally posted by: shashi

    Hello ,
    I 'm develoing the application with CPropertyPage.as u know the look of property sheet is normal trendy type,i want to change the look of property pages which like Excel sheet type that is all tab at the bottom.
    so can u please any body help me for the above,i dont want to derived from Dialog box i would stricktly like to stik with property page Class and wther there is any way to modify or change in CPro... class.

    Thanks in advance,

    shashi

    Reply
  • How to add string to a listbox in one PropPage?

    Posted by Legacy on 08/18/2000 12:00am

    Originally posted by: Jimmy Lee

    If I have a listbox in any one Proppage,
    how can I add a string to that listbox in CMyFormView?

    Reply
  • Does this really work for SDI application?

    Posted by Legacy on 01/21/2000 12:00am

    Originally posted by: Achalla Srinivasu

    Hi,

    I tried your method for my application, which is SDI based.

    But I am not getting things correct. In particular I don't get WM_SIZE,WM_VSCROLL etc. messages to CPropPageView class at all. However, the PropPageView is getting Created. (OnCreate()).


    I don't understand.... Can you please help?....

    Regards,
    Srinivasu. A

    Reply
  • Question

    Posted by Legacy on 01/09/2000 12:00am

    Originally posted by: Anne Neuberger

    I am implementing a property sheet as a pop up dialog when the user clicks on a button in a form view. How do I communicate the results of the property sheet to the form view and its document?
    Thank you

    Reply
  • Tabbing across multiple property sheets?

    Posted by Legacy on 01/06/2000 12:00am

    Originally posted by: Nagesh

    What complexity will it add if we have another property sheet in the form view and we intend to tab across the controls and property sheets? I think it wouldn't work if we just added one more CViewPropertySheet member in the CPropPgFormView.

    Reply
  • No file to download

    Posted by Legacy on 12/29/1999 12:00am

    Originally posted by: netcoder

    http://www.codeguru.com/propertysheet/SheetInView_demo.zip

    The download link is not working please send me the updated download link

    Thanks.

    Reply
Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • Today's agile organizations pose operations teams with a tremendous challenge: to deploy new releases to production immediately after development and testing is completed. To ensure that applications are deployed successfully, an automatic and transparent process is required. We refer to this process as Zero Touch Deployment™. This white paper reviews two approaches to Zero Touch Deployment--a script-based solution and a release automation platform. The article discusses how each can solve the key …

  • Learn How A Global Entertainment Company Saw a 448% ROI Every business today uses software to manage systems, deliver products, and empower employees to do their jobs. But software inevitably breaks, and when it does, businesses lose money -- in the form of dissatisfied customers, missed SLAs or lost productivity. PagerDuty, an operations performance platform, solves this problem by helping operations engineers and developers more effectively manage and resolve incidents across a company's global operations. …

Most Popular Programming Stories

More for Developers

RSS Feeds