Rollout panel






4.48/5 (14 votes)
This article explains how to create rollout panel (like in 3dsmax)
Introduction
This control works like the '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 CodeProject, but the only articles I found were about expanding dialogs, which has limited functionality in comparison with this. So I decided to write my own class for this control.
How to integrate it into existing code
- Create a dialog and place controls on it.
- Encircle controls you want to be dynamically shown or hidden with static box and set it's text to empty string, also place checkbox in the corner of it, as it is shown in the picture
- Set the proper IDs for checkbox and static (do not use
IDC_STATIC
because it will not work!). Let's say you have used IDsIDC_CHTYPE
(for checkbox) andIDC_STTYPE
(for static box) - Associate variables with these two controls using Class Wizard. The should be
of type
CButton
- Copy ExpandingCheck.h and ExpandingCheck.cpp files into your source files directory
- In your dialog's .h file write:
- 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
- In the constructor of your dialog, write:
m_chType.SetFrame(&m_stType);
- That's all!
#include"ExpandingCheck.h"
//{{AFX_DATA(CExpCheckTestDlg) enum { IDD = IDD_EXPCHECKTEST_DIALOG }; CExpandingCheck m_chType; //I have changed this line CButton m_stType; //}}AFX_DATA
If you have found any bugs or improved the code, feel free to email me.