Click here to Skip to main content
16,016,736 members
Articles / Desktop Programming / MFC
Article

Rollout panel

Rate me:
Please Sign up or sign in to vote.
4.48/5 (16 votes)
14 Oct 2002CPOL1 min read 95.6K   2K   27   14
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

  1. Create a dialog and place controls on it.
  2. 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
  3. Set the proper IDs for checkbox and static (do not use IDC_STATIC because it will not work!). Let's say you have used IDs IDC_CHTYPE (for checkbox) and IDC_STTYPE (for static box)
  4. Associate variables with these two controls using Class Wizard. The should be of type CButton
  5. Copy ExpandingCheck.h and ExpandingCheck.cpp files into your source files directory
  6. In your dialog's .h file write:
  7. #include"ExpandingCheck.h" 
  8. 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
  9. //{{AFX_DATA(CExpCheckTestDlg)
    enum { IDD = IDD_EXPCHECKTEST_DIALOG };
    CExpandingCheck m_chType; //I have changed this line
    CButton m_stType;
    //}}AFX_DATA
  10. In the constructor of your dialog, write:
    m_chType.SetFrame(&m_stType); 
  11. That's all!

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

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer IQ Direct
Ukraine Ukraine
Artem is a developer in a software development firm IQ Direct Inc. Attained Electrical Enginnering Ph.D degree in National Technical University of Ukraine "Kyiv Politechnic Institute". Fields of interest: embedded development, web development, automation.

Comments and Discussions

 
NewsSubtle Bug Pin
J.Kaminski10-Oct-07 3:31
J.Kaminski10-Oct-07 3:31 
Generalcant get it to work...help welcome [modified] Pin
rootdial26-Jun-06 4:08
rootdial26-Jun-06 4:08 
GeneralRe: cant get it to work...help welcome [modified] Pin
Artem Moroz26-Jun-06 4:45
Artem Moroz26-Jun-06 4:45 
I've compiled this control both in VS 2003, and VS 2005, it works fine.

I could tell you what is the problem if I see your source. Could you please send me a project? You may erase important commercial data if you wish.

My email is mav_stuff[at]bk.ru


P.S. notify that the normal state of the checkbox is checked, maybe this is the problem ?

Regards,
MAV

-- modified at 10:47 Monday 26th June, 2006
GeneralRe: cant get it to work...help welcome Pin
rootdial26-Jun-06 7:40
rootdial26-Jun-06 7:40 
GeneralRe: cant get it to work...help welcome Pin
Artem Moroz26-Jun-06 9:30
Artem Moroz26-Jun-06 9:30 
GeneralRe: cant get it to work...help welcome Pin
rootdial26-Jun-06 19:12
rootdial26-Jun-06 19:12 
GeneralRe: cant get it to work...help welcome Pin
Vasily Terkin15-Sep-06 4:28
Vasily Terkin15-Sep-06 4:28 
GeneralMaybe Patented Pin
compiler25-Nov-03 12:26
compiler25-Nov-03 12:26 
GeneralRe: Maybe Patented Pin
Synetech1-Jun-05 11:28
Synetech1-Jun-05 11:28 
GeneralRe: Maybe Patented Pin
Rage_bla8-Oct-05 14:21
Rage_bla8-Oct-05 14:21 
Generalwrong refresh Pin
Sancho18-Oct-02 23:26
Sancho18-Oct-02 23:26 
GeneralWell done... Pin
Alessandro Falappa18-Oct-02 7:08
Alessandro Falappa18-Oct-02 7:08 
GeneralMe like, but... Pin
henchook15-Oct-02 22:33
henchook15-Oct-02 22:33 
GeneralNice control... Pin
Marc Clifton15-Oct-02 4:57
mvaMarc Clifton15-Oct-02 4:57 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.