Creating a Rollout Panel



Environment: VC6, Win95-XP

Introduction

This control works like "Rollout panel" in 3dsmax: When you click on a checkbox, some additional controls are shown. Another click on a checkbox will hide controls. Notice that other controls in a dialog are also moved and the dialog itself is resized. I tried to find something like this on the CodeGuru site, but the only articles I found were about expanding dialogs, which have limited functionality in comparison with this. So I decided to write my own class for this control.

How to Integrate It into Existing Code

  1. Create a dialog and place controls on it.
  2. Encircle the controls you want to be dynamically shown or hidden with static box and set their text to an empty string. Also, place a checkbox in the corner of it, as it is shown in the picture.
  3. Set the proper IDs for the checkbox and static (do not use IDC_STATIC because it will not work!). Let's say you have used ID's IDC_CHTYPE (for checkbox) and IDC_STTYPE (for static box).
  4. Associate variables with these two controls using ClassWizard. They should be of type CButton.
  5. Copy the "ExpandingCheck.h" and "ExpandingCheck.cpp" files into your source files directory.
  6. In your dialog's .h file write:
    #include"ExpandingCheck.h"
    
  7. Also, in your dialog's .h file you have to find the variables created in Step 4 and make the Checkbox variable of type CExpandingCheck:
  8.     //{{AFX_DATA(CExpCheckTestDlg)
        enum { IDD = IDD_EXPCHECKTEST_DIALOG };
        CExpandingCheck m_chType;    //I have changed this line
        CButton m_stType;
        //}}AFX_DATA
    
  9. In the constructor of your dialog, write:
  10.     m_chName.SetFrame(&m_stName);
    
  11. That's all!

If you have found any bugs or improved the code, feel free to e-mail me.

Downloads

Download demo project - 36Kb
Download source - 3Kb


Comments

  • Check layout - > Tab order

    Posted by Legacy on 11/07/2003 12:00am

    Originally posted by: Rybets

    After I added this to my app (It was already some controls in dialog), I have seen nothing. We spend a lot of time, checking, what is wrong. Finally, we
    changed a tab order, to make expanding dilogs to be presented first using "tab order". It is OK now.

    Reply
  • How about a button?

    Posted by Legacy on 02/27/2003 12:00am

    Originally posted by: Breeze

    how about if I use a button. Can I use CExpandingCheck or CExpandingButton (if there any)?
    

    Reply
Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • Live Event Date: August 19, 2014 @ 11:00 a.m. ET / 8:00 a.m. PT You deployed your app with the Bluemix PaaS and it's gaining some serious traction, so it's time to make some tweaks. Did you design your application in a way that it can scale in the cloud? Were you even thinking about the cloud when you built the app? If not, chances are your app is going to break. Check out this upcoming webcast to learn various techniques for designing applications that will scale successfully in Bluemix, for the …

  • A majority of organizations are operating under the assumption that their network has already been compromised, or will be, according to a survey conducted by the SANS Institute. With many high profile breaches in 2013 occurring on endpoints, interest in improving endpoint security is top-of-mind for many information security professionals. The full results of the inaugural SANS Endpoint Security Survey are summarized in this white paper to help information security professionals track trends in endpoint …

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds