MFC Feature Pack Tutorial – Part 2 – CMFCPropertySheet

New MFC feature pack property sheet is indeed cool. It’s named as CMFCPropertySheet. We’ve got to work with it as we used to work with CPropertySheet i.e. derive our own class and add pages (CMFCPropertyPage) to it. It’s parent class is as expected, CPropertySheet.

With just one call to CMFCPropertySheet::SetLook member function we can change it’s look and feel. Different looks supported by CMFCPropertySheet is as follows ( its an enum called PropSheetLook)…

  1. PropSheetLook_Tabs
  2. PropSheetLook_OutlookBar
  3. PropSheetLook_Tree
  4. PropSheetLook_OneNoteTabs
  5. PropSheetLook_List

So to change look and feel of our new property sheet we have to call SetLook likewise

  1. SetLook( CMFCPropertySheet::PropSheetLook_OneNoteTabs ); // One note look and feel
  2. SetLook( CMFCPropertySheet::PropSheetLook_OutlookBar ); // Outlook pane look and feel
  3. etc

Ideal place to invoke this call is the constructor of our CMFCPropertySheet derived class. It’s a rule that SetLook should be called just before DoModal or Create.

So that was the tabs part try them out, so how is this done, right? There are dedicated classes for managing these look and feel stuff in a property sheet. If you look up CMFCPropertySheet header you will see the following members…

  • CMFCOutlookBarPaneList m_wndPane1;
  • CMFCPropertySheetTabCtrl m_wndTab;
  • CMFCProperySheetListBox m_wndList;
  • CMFCOutlookBar m_wndOutlookBar; // For outlook
  • CTreeCtrl m_wndTree;

So rest is just coding for switching among tabs. Lets now come to the tab icon part, how to set tab icons, it’s just very easy, call SetIconsList, we don’t even need a bitmap object, just resource id of a bitmap strip along with size of each bitmap. So if we have a bitmap strip called IDB_NIBU 😉 and each bitmap in this strip is 32 pixels wide and high, then call SetIconsList likewise to set tab icons in the constructor of our CMFCPropertySheet derived class…

SetIconsList( IDB_NIBU, 32); // Now we should start seeing our icons

Now, it’s about adding pages, pages for new CMFCPropertySheet should be of type CMFCPropertyPage, here we add two pages to our property sheet.

AddPage(&m_Page1);
AddPage(&m_Page2);

So after all this work how does our new property page look, show us a screenshot man! 😀 Ok ok stop crying here is it… 😛

1. One note style

One note style property sheet tabs

2. Outlook style

Outlook style property sheet

Advertisements
  1. feffe
    December 30, 2009 at 4:17 pm

    But… Is it possible to skin a dialog or a property page???
    I’d like it to have office-style look… Or should they always have system style?

    thanks

    • December 30, 2009 at 4:20 pm

      Yes, the “NewControls” samples in feature pack demonstrates this.

  2. December 6, 2009 at 1:16 pm

    how to change from One note style to Outlook style??

    thanks before.

  3. Sandeep
    October 14, 2009 at 12:17 pm

    How to create dialog box with property sheet look but without tabs,tree etc..

    I need to create simple dialog box with MFC feature pack look

    Thanks
    Sandeep

  4. Amrizal
    April 30, 2009 at 2:31 pm

    How do I create something an app that looks like the screen shots? Is there any codes that I can refer to?

    • April 30, 2009 at 2:33 pm

      Hello Amrizal,

      Please have a look at Part 1 of this tutorial.

      Sincerely,
      NT

  1. June 28, 2008 at 9:33 am

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: