Click here to Skip to main content
15,878,945 members
Articles / Desktop Programming / MFC
Article

Rollup Control

Rate me:
Please Sign up or sign in to vote.
4.94/5 (54 votes)
16 Dec 20032 min read 377.2K   6.5K   118   86
A 3DSMax like Rollup control

Introduction

I wanted the same graphic control that 3DSMax use in the pages 'create' and 'modify'. It is called a 'Rollup Window Control', which allows one to roll and unroll dialog boxes and to scroll them in the control's client area. The CRollupCtrl MFC class is the result. The class definition and implementation are in the files RollupCtrl.h and RollupCtrl.cpp, which are included in the demo project.

Features

  • The control is derived from the CWnd class and can be created in any window.
  • Pages are composed of a title, visualized by a button and a template (the dialog box).
  • Pages can have several states. They can be rolled/unrolled but can also be active and inactive. To roll-unroll a page allows you to hide or show dialog box, respectively. To deactivate a page, lock the dialog box in the rolled state.
  • The control is resizable and can also scroll pages. To scroll pages you can use the scrollbar or click inside an open dialog box and drag outside it to scroll the control.

Using the Control

To use this control in your application, add the RollupCtrl.h and RollupCtrl.cpp files to your project. The creation of the control is made by calling the CRollupCtrl::Create(...) method. There are two ways to insert a page.

  1. RUNTIME_CLASS method

    Create a dialog box in the resource editor 'ex. IDD_PAGE1' with the WS_CHILD style. Generate the declaration and implementation files class (ex. CPage1Dlg) of your dialog box with the assistance of the MFC Classwizard. Then add DECLARE_DYNCREATE(CPage1Dlg) in the declaration of the class and IMPLEMENT_DYNCREATE(CPage1Dlg, CDialog) in the implementation.

    Then insert the page in this way pwndRollupCtrl->InsertPage("Caption", IDD_PAGE1, RUNTIME_CLASS(CPage1Dlg) );

  2. CDialog::Create method

    As RUNTIME_CLASS method, create a dialog box in the resource editor. Generate the declaration and implementation files class of your dialog box. Then create the dialog box like this

    CPage1Dlg* pwndPage1 = new CPage1Dlg;<BR>pwndPage1->Create(MAKEINTRESOURCE(IDD_PAGE1), pwndRollupCtrl);

    and insert the page as follows

    pwndRollupCtrl->InsertPage("Caption", pwndPage1 );

This code has been tested only on W2K. If you have any other suggested improvements, please let me know for the next release.

User Methods

V1.00

BOOL     Create(DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID);
int      InsertPage(const char* caption, CDialog* pwndTemplate,
                   BOOL bAutoDestroyTpl=TRUE, int idx=-1);
int      InsertPage(const char* caption, UINT nIDTemplate, int idx=-1);
int      InsertPage(const char* caption, UINT nIDTemplate, 
                   CRuntimeClass* rtc, int idx=-1);
void     RemovePage(int idx);
void     RemoveAllPages();
void     ExpandPage(int idx, BOOL bExpand=TRUE);    
void     ExpandAllPages(BOOL bExpand=TRUE);
void     EnablePage(int idx, BOOL bEnable=TRUE);
void     EnableAllPages(BOOL bEnable=TRUE);
RC_PAGEINFO* CRollupCtrl::GetPageInfo(int idx); 

V1.01

void     ScrollToPage(int idx, BOOL bAtTheTop=TRUE);
int     MovePageAt(int idx, int newidx);
BOOL     IsPageExpanded(int idx);
BOOL     IsPageEnabled(int idx);
int     GetPagesCount();

V1.02

BOOL     IsAutoColumnsEnabled();
void     EnableAutoColumns(BOOL bEnable=TRUE);
BOOL     SetColumnWidth(int nWidth);
BOOL     SetPageCaption(int idx, LPCSTR caption); 

History

  • v1.0
    31/03/01: Created
  • v1.01
    13/04/01: Added ScrollToPage method
    Added automatic page visibility to ExpandPage method
    Added Mousewheel support
    15/04/01: Added mouse capture checking on WM_MOUSEMOVE dialog msg
    Added SetCursor on Dialog WM_SETCURSOR
    Added MovePageAt method
    17/04/01: Fixed Group Boxes displayed over Buttons
    20/04/01: Added IsPageExpanded and IsPageExpanded methods
    Added PopupMenu
    Added Button subclassing (now button's focus not drawn)
  • v1.02
    10/06/02: Added pages dividing up into columns
    17/06/02: Added SetPageCaption method
    19/11/02: Fixed _RemovePage method
    29/10/03: Background color for AfxRegisterWndClass

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
France France
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
Questioncontrols on page not working Pin
turtletyper17-Feb-18 2:11
turtletyper17-Feb-18 2:11 
GeneralMy vote of 5 Pin
calmman.yang28-Feb-12 23:31
calmman.yang28-Feb-12 23:31 
GeneralMy vote of 5 Pin
lwonc29-Dec-11 16:12
lwonc29-Dec-11 16:12 
QuestionIntegrated with "Rollup Control" with "Simple Tab Control For Visual C++" possible? Pin
akira3214-Jan-09 7:20
akira3214-Jan-09 7:20 
GeneralA Very Good Tool Pin
Chandrasekharan P15-Sep-08 1:04
Chandrasekharan P15-Sep-08 1:04 
GeneralHelp please - incorporating Rollup into a Dialog Based MFC Application Pin
RobbieGregg3-Sep-08 22:57
RobbieGregg3-Sep-08 22:57 
GeneralDinamical adding a new button or edit box Pin
Member 414549316-Apr-08 6:14
Member 414549316-Apr-08 6:14 
GeneralMDI application and RollUp Pin
Laursl19-Nov-07 23:20
Laursl19-Nov-07 23:20 
GeneralRe: MDI application and RollUp Pin
Laursl20-Nov-07 2:36
Laursl20-Nov-07 2:36 
Generalso great Pin
dazedase17-Aug-07 17:41
dazedase17-Aug-07 17:41 
GeneralInsert &quot;Rollup Controls&quot; into Tabs Pin
saviorman19-Oct-05 15:06
saviorman19-Oct-05 15:06 
theres somebody who knows how can this be done ?Confused | :confused:
I've been trying it combining it with the Sizing TabControlBar (by Dirk Clemens)

http://www.codeproject.com/docking/sizing_tabctl.asp?msg=531363

but, i can't make it work at all !Mad | :mad:
Maybe is easier than it seems to be... ¿?

any ideas?
GeneralFeature Request Pin
Bob McCown15-Oct-04 2:39
Bob McCown15-Oct-04 2:39 
QuestionC#/.Net/WinForms version? Pin
jeffb4218-Jun-04 15:56
jeffb4218-Jun-04 15:56 
Generalcustom control flickers Pin
Isidor18-Jan-04 6:27
Isidor18-Jan-04 6:27 
QuestionHow to make a Dockable &quot;TabPan&quot; with this DialogBar just like 3DS MAX ? Pin
sgy2321-Dec-03 23:29
sgy2321-Dec-03 23:29 
QuestionCan someone forward the source code to me?? Thanks!! Pin
Paul Groetzner2-Dec-03 13:21
Paul Groetzner2-Dec-03 13:21 
AnswerRe: Can someone forward the source code to me?? Thanks!! Pin
aseemann3-Dec-03 20:52
aseemann3-Dec-03 20:52 
GeneralRe: Can someone forward the source code to me?? Thanks!! Pin
kiran_ts4-Dec-03 5:57
kiran_ts4-Dec-03 5:57 
GeneralRe: Can someone forward the source code to me?? Thanks!! Pin
Paul Groetzner5-Dec-03 4:34
Paul Groetzner5-Dec-03 4:34 
GeneralAnother fix to _RemovePage method Pin
Zaffari2-Dec-03 8:07
Zaffari2-Dec-03 8:07 
QuestionSource 404? Pin
Ravi Bhavnani25-Nov-03 6:04
professionalRavi Bhavnani25-Nov-03 6:04 
GeneralPatented Pin
compiler22-Nov-03 19:01
compiler22-Nov-03 19:01 
GeneralRe: Patented Pin
Sven Axelsson17-Dec-03 2:42
Sven Axelsson17-Dec-03 2:42 
GeneralRe: Patented Pin
Triac8-Jan-04 21:26
Triac8-Jan-04 21:26 
GeneralRe: Patented Pin
steblublu17-Feb-06 4:02
steblublu17-Feb-06 4:02 

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.