CResizableSheet(Ex) and CResizablePage(Ex)

These four classes handle resizable property sheets, wizards and the wizard 97 style dialogs, and are now fully based on my ResizableLib class library (see article).

The user will have the ability to resize the dialog, with consequent rearrangement of child windows. You can control the minimum and maximum size allowed, as well as the maximized size and position of the dialog. The size grip is displayed by default, but you may turn it off. Automatic Save/Restore the dialog's size and position, along with the active page, is also supported.

Conversion of a previously existant property sheet or wizard should be very simple.

I will talk about non-Ex classes for the rest of the article, but the same concepts applies for Wizard 97 dialogs.

The Sample Applications

This is a view of the sample dialog at minimum size as a property sheet and in wizard mode:

Note that the minimum width is not the default. You may see how to do this in the next section.

This is a screenshot of the resizable version of Wizard97 sample project coming with Visual C++.

Usage - Step by Step

Add the ResizableLib to your project's workspace, as explained in the relative article.

Create a property sheet or wizard dialog and do the relative associations with MFC classes, for example using the Property Sheet component, or take one you have already made which you want to be resizable. You don't need to change any window style to have the dialog resizing.

Include 'ResizableSheet.h' in the property sheet associated header file.

Search and replace all CPropertySheet occurences with CResizableSheet in both your .cpp and .h files, just as if your property sheet class was derived from CResizableSheet instead of CPropertySheet.

Include 'ResizablePage.h' in the property pages associated header file.

Search and replace all CPropertyPage occurences with CResizablePage in both your .cpp and .h files, just as if your property page classes were derived from CResizablePage instead of CPropertyPage.

In each page's OnInitDialog override you only have to set a layout for your controls. You specify where to attach the top-left and bottom-right corners by horizontal/vertical percentage or using predefined constants.

CResizablePage::CResizablePage

The second and the third forms are needed to reproduce the construction scheme of a CPropertySheet/Page derived class. Since the dialog resource template is needed by the CPropertySheet/Page constructor, you have to call one of these forms of the CResizableSheet/Page constructor. This is the reason why replacing one class with the other will work.

CResizableSheet::EnableSaveRestore

Enables automatic save/restore on dialog's open/close operations. The first argument is the same as in CWinApp::WriteProfileString. If bRectOnly is TRUE, the minimized/maximized state is not saved/restored. The last argument is a flag for restoring the active page (active page is always saved). Should be called after all the layout settings.

If you want details on how these settings are stored, look at CWinApp::SetRegistryKey, CWinApp::m_pszProfileName, CWinApp::m_pszRegistryKey on MFC documentation.

CResizable???::???

Member functions to set/reset maximized size and position may seem rather useless, since you don't have a maximize box in the window's caption. I left them because I think it should be possible to enable caption buttons, playing a little with window's styles.

Conclusion

I hope these classes can make some programmers' life a little easier. I also want to thank Jerzy Kaczorowski for his unique support during the port of CResizableDialog code to property sheets.

Integration with ResizableLib is now complete. This required a partial rewriting, but I hope it will benefit of all the improvements made to the library (and the bugs too).

Share

About the Author

Paolo began programming at the age of 9 with a glorious 8086 and GW-BASIC, then he played a bit with C, ASM and Pascal. He tought himself MFC and Windows programming, to exploit his studies of C++. Always attracted by low-level programming and Assembly, he's beginning to appreciate the joys of templates and STL. At work he changed his mind about Java, discovered Eclipse IDE, and now think it's cool.

Comments and Discussions

In my application the propertysheets are modeless. The first time the sheet and its pages are brought up, the sizes are correct. However next time that the sheet and its pages are brought up, size of the sheet and placement of the p[ages has changed, does anyone know whether it is possible at all to use this library for modeless property sheets and pages?