I recently needed a wizard that could be resized by the
user. After looking around on CodeGuru I found nothing that would do this
completely so I created my own (since I have taken so much code and ideas from
CodeGuru, I felt that the time had come to give something back).
After a while I came up with the class
CResizablePropertySheet. It is derived from the MFC CPropertySheet class and
handles the resizing of the standard wizard buttons, the tab control and the
pages included in the sheet. The CResizablePropertySheet uses a class
CDlgItemResizer that handles the resizing of the controls in the property sheet.
In an article written by Eli Vingot (elivingt@internet-zahav.net) implementing a resizable dialog, I found
some great code. I have been writing control-resizing code manually for almost
10 years and the idea just never came to me that this could be automated. Eli
Vingot’s code really takes the pain out of resizing.
To use the CResizablePropertySheet class, just use it as
you would use the MFC CPropertySheet. If you have already derived your own sheet
from the CPropertySheet, just replace all occurrences of CPropertySheet to
CResizablePropertySheet.
The next thing to do is to handle the resizing in all of
the included pages. Create a page the normal way and declare a CDlgItemResizer
member variable inside it. Also, add the OnInitDialog() and OnSize() member
functions. In the OnInitDialog() function, use the CDlgItemResizer::Add()
routine to add all the controls that are to be resized. Make sure to use the
correct combination of the resizing flags (lock to top/left/right/bottom). In
the OnSize() member function, add a single line of code to resize all controls:
call the CDlgItemResizer::Resize().
Downloads
History