Click here to Skip to main content
15,867,308 members
Articles / Desktop Programming / WTL
Article

WTL Rolldown Control

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

Sample Image - WtlRolldownCtrl.gif

Introduction

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.

Requirements

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"));
    m_RolloutContainer.AddRollout(m_dlg1);

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_RolloutContainer.Create(m_hWnd);
  ...
  m_dlg1.Create(m_RolloutContainer.m_hWnd, _T("Rollout Control 1"));
  m_RolloutContainer.AddRollout(m_dlg1);
  m_dlg2.Create(m_RolloutContainer.m_hWnd, _T("Rollout Control 2"));
  m_RolloutContainer.AddRollout(m_dlg2);
  m_dlg3.Create(m_RolloutContainer.m_hWnd, _T("Rollout Control 3"));
  m_RolloutContainer.AddRollout(m_dlg3);
  ...
}

CRolloutCtrl User Methods:

Creation

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

Attributes

bool IsExpanded();

Returns true if the control is expanded or false otherwise.

Operations

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:

Creation

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

Operations

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.

Updates

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.

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
Web Developer
Germany Germany
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
Questionone question [modified] Pin
bobtnt17-Oct-07 3:40
bobtnt17-Oct-07 3:40 
GeneralHere's how to get this compiling in VS 2005... Pin
Pallium3-Apr-07 14:09
Pallium3-Apr-07 14:09 
You'll need to make two small changes.

First, at line 656, change the declaration of CRolloutCtrl from:

template <class TChild><br />
class CRolloutCtrl : public CRolloutCtrlImpl<CRolloutCtrl, TChild><br />
{<br />
public:<br />
	DECLARE_WND_SUPERCLASS(_T("WTL_RolloutCtrl"), GetWndClassName())<br />
<br />
	CRolloutCtrl() : CRolloutCtrlImpl<CRolloutCtrl, TChild>()<br />
	{ }<br />
};


to

template <class TChild><br />
class CRolloutCtrl : public CRolloutCtrlImpl<CRolloutCtrl<span style="color:#0000ff;"><TChild></span>, TChild><br />
{<br />
public:<br />
	DECLARE_WND_SUPERCLASS(_T("WTL_RolloutCtrl"), GetWndClassName())<br />
<br />
	CRolloutCtrl() : CRolloutCtrlImpl<CRolloutCtrl<span style="color:#0000ff;"><TChild></span>, TChild>()<br />
	{ }<br />
};


Second, at line 586, change the PostMessage call from:

::PostMessage(GetParent(), uMsg, (WPARAM)GetParent(), lParam);

to

::PostMessage(GetParent(), uMsg, (WPARAM)<span style="color:#0000ff;">(HWND)</span>GetParent(), lParam);

At least in the demo source, both Xuewu Liu's and Paul Bludov's comments appear unfixed, so you might want to address those too.
GeneralUse in Dialog Pin
peter@howudodat.com29-Dec-04 10:12
peter@howudodat.com29-Dec-04 10:12 
GeneralUnable to use Controls Pin
Mephisto18718-Jan-04 23:55
Mephisto18718-Jan-04 23:55 
GeneralA little bug :P Pin
Xuewu Liu4-Jan-04 16:08
Xuewu Liu4-Jan-04 16:08 
GeneralA little bug :P Pin
Xuewu Liu4-Jan-04 16:07
Xuewu Liu4-Jan-04 16:07 
GeneralAlso Patented Pin
compiler25-Nov-03 12:25
compiler25-Nov-03 12:25 
GeneralRe: Also Patented Pin
Vadim Tabakman27-May-04 14:04
Vadim Tabakman27-May-04 14:04 
GeneralRe: Also Patented Pin
Member 98304510-Aug-04 13:46
Member 98304510-Aug-04 13:46 
GeneralBackground Color of Controls Pin
Mephisto18713-Oct-03 0:53
Mephisto18713-Oct-03 0:53 
GeneralDialog box implementation Pin
Modar4-May-03 8:02
Modar4-May-03 8:02 
GeneralRe: Dialog box implementation Pin
Mephisto18717-Aug-03 21:59
Mephisto18717-Aug-03 21:59 
Generallots of flicker Pin
Todd Smith5-Mar-02 12:57
Todd Smith5-Mar-02 12:57 
GeneralContext menu bug Pin
Paul Bludov10-Feb-02 23:17
Paul Bludov10-Feb-02 23:17 
GeneralRe: Context menu bug Pin
Bjoern Graf1-Mar-02 11:23
Bjoern Graf1-Mar-02 11:23 
GeneralRe: Context menu bug Pin
Pallium3-Apr-07 14:23
Pallium3-Apr-07 14:23 
Generalok Pin
Ramon Smits14-Sep-01 11:47
Ramon Smits14-Sep-01 11:47 
GeneralRe: ok Pin
Bjoern Graf1-Oct-01 3:52
Bjoern Graf1-Oct-01 3:52 
GeneralGreat time saving... Pin
Paul Selormey3-Sep-01 18:35
Paul 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.