Resizable CPropertySheet | CodeGuru

Resizable CPropertySheet

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 […]

Written By
CodeGuru Staff
CodeGuru Staff
Jul 13, 1999
2 minute read
CodeGuru content and product recommendations are editorially independent. We may make money when you click on links to our partners. Learn More


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

Download demo project – 20 Kb

History

CodeGuru Logo

CodeGuru covers topics related to Microsoft-related software development, mobile development, database management, and web application programming. In addition to tutorials and how-tos that teach programmers how to code in Microsoft-related languages and frameworks like C# and .Net, we also publish articles on software development tools, the latest in developer news, and advice for project managers. Cloud services such as Microsoft Azure and database options including SQL Server and MSSQL are also frequently covered.

Property of TechnologyAdvice. © 2026 TechnologyAdvice. All Rights Reserved

Advertiser Disclosure: Some of the products that appear on this site are from companies from which TechnologyAdvice receives compensation. This compensation may impact how and where products appear on this site including, for example, the order in which they appear. TechnologyAdvice does not include all companies or all types of products available in the marketplace.