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.
- 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.
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
CDialog) in the implementation.
Then insert the page in this way
pwndRollupCtrl->InsertPage("Caption", IDD_PAGE1, RUNTIME_CLASS(CPage1Dlg) );
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.
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 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);
void ScrollToPage(int idx, BOOL bAtTheTop=TRUE);
int MovePageAt(int idx, int newidx);
BOOL IsPageExpanded(int idx);
BOOL IsPageEnabled(int idx);
void EnableAutoColumns(BOOL bEnable=TRUE);
BOOL SetColumnWidth(int nWidth);
BOOL SetPageCaption(int idx, LPCSTR caption);
Added automatic page visibility to
Added Mousewheel support
15/04/01: Added mouse capture checking on
WM_MOUSEMOVE dialog msg
SetCursor on Dialog
17/04/01: Fixed Group Boxes displayed over Buttons
Added Button subclassing (now button's focus not drawn)
10/06/02: Added pages dividing up into columns
29/10/03: Background color for
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.