Click here to Skip to main content
14,979,401 members
Articles / Desktop Programming / WTL
Posted 3 Sep 2001


42 bookmarked

WTL Rolldown Control

Rate me:
Please Sign up or sign in to vote.
4.93/5 (9 votes)
4 Mar 20023 min read
A WTL Rolldown control as seen in 3DSMax

Sample Image - WtlRolldownCtrl.gif


Even thought this implementation seems to be a port of the MFC Rollup Control by Johann Nadalutti, I started to develop it some days before the first post of the above-mentioned article. Nevertheless, I need to thank Johann Nadalutti for his great work that gave me the opportunity to improve my implementation.

This implementation consists of two classes: CRolldownCtrl<TChild> implements the actual Rolldown control while CRolldownContainer implements a manager, which provides the visual area for the Rolldown controls.
The class definitions and implementations are in the file AtlRolldownCtrl.h, which are included in the demo project.


You will require the WTL Libraries; these can be downloaded from the Microsoft site. If the WTL Libraries have no meaning to you, see Introduction to WTL - Part 1.

How to use the control in your WTL App

To use this control in your application, add the header file AtlRolldownCtrl.h to your project and then add CRolloutContainer m_RolloutContainer; to the class definition that will be using the control.

  1. Create a dialog box in the resource editor with the WS_CHILD style and its WTL dialog class as usual (e.g. CDlg1).
    Note: Trap IDOK and IDCANCEL else the dialog will be destroyed if the user presses either RETURN or ESC.
  2. Add CRolloutCtrl<CDlg1> m_dlg1; to the class declaration that will be using the control.
  3. Create the control in the OnCreate function and add it to the container, e.g.:
    m_dlg1.Create(m_RolloutContainer.m_hWnd, _T("My Rollout Control"));

Repeat these steps for additional Rolldown controls.

The final OnCreate function may look like this:

LRESULT OnCreate(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
  m_dlg1.Create(m_RolloutContainer.m_hWnd, _T("Rollout Control 1"));
  m_dlg2.Create(m_RolloutContainer.m_hWnd, _T("Rollout Control 2"));
  m_dlg3.Create(m_RolloutContainer.m_hWnd, _T("Rollout Control 3"));

CRolloutCtrl User Methods:


HWND Create(HWND hWndParent, LPCTSTR szWindowName, _U_RECT rect = NULL,
            DWORD dwStyle = 0, DWORD dwExStyle = 0, DWORD dwExRcStyle = 0,
            UINT nID = 0U, LPVOID lpCreateParam = NULL);
BOOL SubclassWindow(HWND hWnd);


bool IsExpanded();

Returns true if the control is expanded or false otherwise.


void GetRect(bool fExpanded, RECT* pRect);

Returns the bounding rectangle of the expanded (fExpanded = true) or collapsed (fExpanded = false) control.

void Expand(bool fExpand = true);
void ToggleExpandCollapse();

Expands (fExpand = true) or collapses (fExpand = false) the control.

CRolloutContainer User Methods:


HWND Create(HWND hWndParent, LPCTSTR lpstrTitle = NULL, DWORD dwStyle = 0,
            DWORD dwExStyle = 0, UINT nID = 0, LPVOID lpCreateParam = NULL);
HWND Create(HWND hWndParent, UINT uTitleID, DWORD dwStyle = 0,
            DWORD dwExStyle = 0, UINT nID = 0, LPVOID lpCreateParam = NULL);


void GetClientSize(SIZE* pClientSize);

Returns the size the container needs to display all Rolldown controls.

int GetSpacing();
void SetSpacing(int nSpacing);

Gets and sets the inter Rolldown spacing.

int AddRollout(HWND hWndRollout);

Adds a Rolldown control to the container. If the return value is greater than or equal to 0, it is the zero-based index to the Rolldown control in the container. The return value is -1 if an error occurs.

bool RemoveRollout(HWND hWndRollout);
bool RemoveRollout(int nIndex);
bool RemoveAllRollouts();

Removes one or all Rolldown controls from the container.

int GetRolloutCount();

Retrieves the count of contained Rolldown controls.

HWND GetRollout(int nIndex);

Retrieves the window handle of a Rolldown control.

void ExpandRollout(HWND hWndRollout, bool fExpand = true, bool fUpdate = true);
void ExpandRollout(int nIndex, bool fExpand = true, bool fUpdate = true);
void ExpandAllRollouts(bool fExpand = true);

Expands (fExpand = true) or collapses (fExpand = false) one or all Rollout controls. If fUpdate is set to true, the layout will be recalculated.

bool IsRolloutExpanded(HWND hWndRollout);
bool IsRolloutExpanded(int nIndex);

Returns true if the control is expanded or false otherwise.

void RolloutEnabled(HWND hWndRollout, bool fEnable);
void RolloutEnabled(int nIndex, bool fEnable);

Enables (fEnable = true) or disables (fEnable = false) the specified rollout control.

bool IsRolloutEnabled(HWND hWndRollout);
bool IsRolloutEnabled(int nIndex);

Returns true if the control is enabled or false otherwise.

void ScrollToRollout(HWND hWndRollout);
void ScrollToRollout(int nIndex);

Scrolls the specified Rolldown control into view.


04 Sep 2001

Initial public release.

28 Sep 2001

Added Copyright/Disclaimer header.
Added flag to update the layout to ExpandRollout().
Changed the context menu. The Close Rollout item will be grayed out if the cursor is not over a rollout.
Changed rollout container message names from RCM_* to RCCM_*.
Fixed page dragging.
Fixed focus drawing.

4 Dec 2001

Added CRolloutCtrlButton to support tabing.
Added EnableRollout() to CRolloutContainer.
Fixed tabbing.

05 Mar 2002

Grayed context menu items of disabled rollout controls. CRolloutContainer::ExpandRollout and CRolloutCtrl::Expand still expand disabled rollout controls.

Known Limitations/Bugs

  • Inconsistent naming of the control within this article.


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

Bjoern Graf
Web Developer
Germany Germany
No Biography provided

Comments and Discussions

Questionone question [modified] Pin
bobtnt17-Oct-07 3:40
Memberbobtnt17-Oct-07 3:40 
GeneralHere's how to get this compiling in VS 2005... Pin
Pallium3-Apr-07 14:09
MemberPallium3-Apr-07 14:09 
GeneralUse in Dialog Pin
peter@howudodat.com29-Dec-04 10:12
Memberpeter@howudodat.com29-Dec-04 10:12 
GeneralUnable to use Controls Pin
Mephisto18718-Jan-04 23:55
MemberMephisto18718-Jan-04 23:55 
GeneralA little bug :P Pin
Xuewu Liu4-Jan-04 16:08
MemberXuewu Liu4-Jan-04 16:08 
GeneralA little bug :P Pin
Xuewu Liu4-Jan-04 16:07
MemberXuewu Liu4-Jan-04 16:07 
GeneralAlso Patented Pin
compiler25-Nov-03 12:25
Membercompiler25-Nov-03 12:25 
GeneralRe: Also Patented Pin
Vadim Tabakman27-May-04 14:04
MemberVadim Tabakman27-May-04 14:04 
GeneralRe: Also Patented Pin
Member 98304510-Aug-04 13:46
MemberMember 98304510-Aug-04 13:46 
GeneralBackground Color of Controls Pin
Mephisto18713-Oct-03 0:53
MemberMephisto18713-Oct-03 0:53 
GeneralDialog box implementation Pin
Modar4-May-03 8:02
MemberModar4-May-03 8:02 
GeneralRe: Dialog box implementation Pin
Mephisto18717-Aug-03 21:59
MemberMephisto18717-Aug-03 21:59 
Generallots of flicker Pin
Todd Smith5-Mar-02 12:57
MemberTodd Smith5-Mar-02 12:57 
GeneralContext menu bug Pin
Paul Bludov10-Feb-02 23:17
MemberPaul Bludov10-Feb-02 23:17 
GeneralRe: Context menu bug Pin
Bjoern Graf1-Mar-02 11:23
MemberBjoern Graf1-Mar-02 11:23 
GeneralRe: Context menu bug Pin
Pallium3-Apr-07 14:23
MemberPallium3-Apr-07 14:23 
Generalok Pin
Ramon Smits14-Sep-01 11:47
MemberRamon Smits14-Sep-01 11:47 
GeneralRe: ok Pin
Bjoern Graf1-Oct-01 3:52
MemberBjoern Graf1-Oct-01 3:52 
GeneralGreat time saving... Pin
Paul Selormey3-Sep-01 18:35
MemberPaul Selormey3-Sep-01 18:35 

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.