The Wayback Machine - https://web.archive.org/web/20160719220338/http://www.codeguru.com:80/cpp/controls/propertysheet/sizing/article.php/c599/Resizable-CPropertySheet.htm

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 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



Comments

  • nPyZOi BU aH YhX SAPO np

    Posted by RwHPBkEXXv on 06/22/2013 03:47pm

    buy tramadol best place to buy tramadol online reviews - tramadol 50mg norsk

    Reply
  • add minimize & maximize buttons

    Posted by div!sion on 10/19/2009 06:04am

    You can add the window minimize and maximize buttons by adding "WS_MAXIMIZEBOX|WS_MINIMIZEBOX" to ModifyStyle called at the end of CResizablePropertySheet::OnInitDialog().

    Reply
  • CResizablePropertySheet Multiple Instance Crashes Application

    Posted by Legacy on 09/29/2003 12:00am

    Originally posted by: Ninad Shah

    Hello There,
    
    I am using CResizablePropertySheet in my program by extending that class as follows:


    void CMyClass::SHowProperty()
    {
    /* Extends CResizablePropertySheet */
    CMyPropertySheet *sheet = new CMyPropertySheet(this);

    /*Extends CResizablePropertyPage */
    CMyPage *page = new CMyPage(this);

    sheet->AddPage(page);
    sheet->Create(this);
    }

    I am calling this function several times as and when user clicks on a row in table. User may not have closed the earlier opened property sheet while he is clicking on another row.

    The property page comes up properly in first click, but next time when user clicks on a row to open property sheet, the whole application crashes.

    Is thet any clue to this problem.

    I highly appreciate any help on this.

    Thanks in advance.

    • help

      Posted by wanganjun78 on 06/07/2004 01:38am

      Can you give me some advice about thiss problem

      Reply
    Reply
  • DlgItemResizer.Resize() changes z-order

    Posted by Legacy on 08/14/2003 12:00am

    Originally posted by: Mike Lischke

    I'm perplex that nobody every realized that the DeferWindowPos calls in the Resize method currently change the z-order of the windows (or didn't they just tell us?). This has ugly side effects like controls on a group box suddenly disappear because they are now behind the box.

    The solution for this problem is pretty simple. Replace the last value (0) in the DeferWindowPos calls by SWP_NOZORDER and bob's your uncle.

    Mike
    --
    www.delphi-gems.com
    www.lischke-online.de
    www.delphi-unicode.net

    • How to change "DlgItemResizer.Resize() changes z-order"

      Posted by ken123 on 11/18/2004 01:04pm

      How do you go by doing it? Can you show us by example on how to "Replace the last value (0) in the DeferWindowPos calls by SWP_NOZORDER" Thanks.

      Reply
    Reply
  • Good code. Thanks a lot.

    Posted by Legacy on 03/13/2003 12:00am

    Originally posted by: rm_pkt

    Thanks a lot Magnus.
    It is very useful to me as I need Resizeable Property sheet.

    And thanks to KL (2000/05/26). Its really good idea for
    modeless in standard mode

    Reply
  • CDlgItemResizer::Resize(CFormView *) not implemented

    Posted by Legacy on 02/01/2002 12:00am

    Originally posted by: Ian

    Magnus,

    Great code, thank you. I've just worked into my project and your work has shaved days of my development schedule.

    Just wondering why the Resize(CFormView*) method isn't implemented on CDlgItemResizer?

    I only discovered the omission when I decided to reuse your resizer class in a form view. It seems to work it we use the CWnd* method instead, but I was wondering what the specialisation was intended to do?

    Anyone got any ideas?

    Ian

    Reply
  • Problems with displaying property pages

    Posted by Legacy on 12/18/2001 12:00am

    Originally posted by: Alexander Vogt

    I tried to use the classes with a property sheet that I create at runtime. Everything works fine, but after resizing, the content of the active property page is gone. One has to change onto another tab first, and then go back again, to see the list-control it contains. I tried to insert several kinds of redraws, but it didn't work.
    I'm really not an expert at MFC , and the solution may e simple. Could anyone help?

    thanks

    Alex

    Reply
  • Problem: Flickering on resize

    Posted by Legacy on 09/01/2001 12:00am

    Originally posted by: Simon

    Hi,
    anybody knows how to remove flickering on resizing of the property sheet ?

    Reply
  • Problems Resizing X-Axis

    Posted by Legacy on 11/15/2000 12:00am

    Originally posted by: Andreas Lander

    Resizing the Height of the Propertysheet is no problem, but i cant resize the X-Axis...

    Reply
  • Modeless Issues in Standard Mode

    Posted by Legacy on 05/26/2000 12:00am

    Originally posted by: KL

    These issues appear when running the property sheet as 
    
    modeless in standard mode. You can recreate them in the
    demo project by making CResizablePropertySheet modeless:

    1. The initial property page appears blank until you switch
    to a different page then switch back.

    2. When resizing a page the controls disappear from the
    page.

    As Paul Hurley pointed out, 'm_rcClient' and 'm_rcPage' are
    used by GetPageRect() before they are initialized in
    OnInitDialog(). Yet clearing them in the constructor
    doesn't allow GetPageRect() to get the right values. Thus
    the controls are drawn somewhere off the property page.

    To get around this problem I added the flag
    'm_bInitialized' to CResizablePropertySheet. I set it
    to 'false' in the constructors and to 'true' at the end of
    OnInitDialog() before returning. Then I added this line to
    OnSize() after 'InvalidateRect(m_rcGripper, TRUE);':

    if(!m_bInitialized) return;

    Now everything seems to be working just fine.

    Reply
  • Loading, Please Wait ...

Top White Papers and Webcasts

  • Microsoft® Office 365 is a top choice for enterprises that want a cloud-based suite of productivity/ collaboration applications. With Office 365, you get access to Microsoft™ Office solutions practically anytime, anywhere, on virtually any device. It's a great option for current Microsoft users who can now build on their experience with Microsoft™ solutions while enjoying the flexibility of a cloud-based delivery. But even organizations with no previous investment in Microsoft will find that …

  • Live Event Date: July 28, 2016 @ 1:00 p.m. ET / 10:00 a.m. PT Jepsen tests are third-party tests for distributed databases that validate vendors' guarantees about how they perform under various failure scenarios, especially network partitions. These have proven their value as tools in any distributed system tester's arsenal. When the creator of Jepsen, Kyle Kingsbury, started his Jepsen-for-Hire business last fall, VoltDB immediately got in line, and over the past two months, our solution was given the most …

Most Popular Programming Stories

More for Developers

RSS Feeds

Thanks for your registration, follow us on our social networks to keep up-to-date