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)…
So to change look and feel of our new property sheet we have to call SetLook likewise
- SetLook( CMFCPropertySheet::PropSheetLook_OneNoteTabs ); // One note look and feel
- SetLook( CMFCPropertySheet::PropSheetLook_OutlookBar ); // Outlook pane look and feel
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.
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
2. Outlook style