
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.
- 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.
- Add
CRolloutCtrl<CDlg1> m_dlg1; to the class
declaration that will be using the control.
- 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 , WPARAM , LPARAM , BOOL& )
{
...
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.