5,696,038 members and growing! (13,253 online)
Email Password   helpLost your password?
Desktop Development » Miscellaneous » Custom Controls     Intermediate

Rollup Control

By Johann Nadalutti

A 3DSMax like Rollup control
VC6, C++Windows, Win2K, MFC, VS6, Visual Studio, Dev

Posted: 12 Apr 2001
Updated: 16 Dec 2003
Views: 174,162
Bookmarked: 87 times
Announcements
Loading...



Search    
Advanced Search
Sitemap
135 votes for this Article.
Popularity: 9.58 Rating: 4.49 out of 5
2 votes, 4.2%
1
3 votes, 6.3%
2
1 vote, 2.1%
3
2 votes, 4.2%
4
40 votes, 83.3%
5

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;
    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

About the Author

Johann Nadalutti



Location: France France

Other popular Miscellaneous articles:

Article Top
Sign Up to vote for this article
You must Sign In to use this message board.
FAQ FAQ Noise ToleranceSearch Search Messages 
 Layout  Per page   
 Msgs 1 to 25 of 82 (Total in Forum: 82) (Refresh)FirstPrevNext
GeneralA Very Good ToolmemberChandrasekharanp2:04 15 Sep '08  
GeneralHelp please - incorporating Rollup into a Dialog Based MFC ApplicationmemberRobbieGregg23:57 3 Sep '08  
GeneralDinamical adding a new button or edit boxmemberMember 41454937:14 16 Apr '08  
GeneralMDI application and RollUpmemberLaursl0:20 20 Nov '07  
GeneralRe: MDI application and RollUpmemberLaursl3:36 20 Nov '07  
Generalso greatmemberdazedase18:41 17 Aug '07  
GeneralInsert "Rollup Controls" into Tabsmembersaviorman16:06 19 Oct '05  
GeneralFeature RequestmemberBob McCown3:39 15 Oct '04  
GeneralC#/.Net/WinForms version?memberjeffb4216:56 18 Jun '04  
Generalcustom control flickersmemberIsidor7:27 18 Jan '04  
GeneralHow to make a Dockable "TabPan" with this DialogBar just like 3DS MAX ?membersgy230:29 22 Dec '03  
GeneralCan someone forward the source code to me?? Thanks!!memberunivega_r30414:21 2 Dec '03  
GeneralRe: Can someone forward the source code to me?? Thanks!!memberaseemann21:52 3 Dec '03  
GeneralRe: Can someone forward the source code to me?? Thanks!!memberkiran_ts6:57 4 Dec '03  
GeneralRe: Can someone forward the source code to me?? Thanks!!memberunivega_r3045:34 5 Dec '03  
GeneralAnother fix to _RemovePage methodmemberZaffari9:07 2 Dec '03  
GeneralSource 404?memberRavi Bhavnani7:04 25 Nov '03  
GeneralPatentedmembercompiler20:01 22 Nov '03  
GeneralRe: PatentedmemberSven Axelsson3:42 17 Dec '03  
GeneralRe: PatentedmemberTriac22:26 8 Jan '04  
GeneralRe: Patentedmembersteblublu5:02 17 Feb '06  
Generaldrag page to repositionmembersovann0:43 21 Nov '03  
GeneralWerks great. I love it.memberKeith Ackermann11:20 17 Nov '03  
Generalnicememberl a u r e n6:52 12 Nov '03  
GeneralFantastic controlmemberBadJerry0:21 12 Nov '03  

General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

PermaLink | Privacy | Terms of Use
Last Updated: 16 Dec 2003
Editor: Nishant Sivakumar
Copyright 2001 by Johann Nadalutti
Everything else Copyright © CodeProject, 1999-2008
Web20 | Advertise on the Code Project