Click here to Skip to main content
Click here to Skip to main content

WTL Rolldown Control

By , 4 Mar 2002
Rate this:
Please Sign up or sign in to vote.
<!-- Download Links --> <!-- Article image -->

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

About the Author

Bjoern Graf
Web Developer
Germany Germany
No Biography provided

Comments and Discussions

 
Questionone question [modified] Pinmemberbobtnt17-Oct-07 3:40 
GeneralHere's how to get this compiling in VS 2005... PinmemberPallium3-Apr-07 14:09 
GeneralUse in Dialog Pinmemberpeter@howudodat.com29-Dec-04 10:12 
GeneralUnable to use Controls PinmemberMephisto18718-Jan-04 23:55 
GeneralA little bug :P PinsussXuewu Liu4-Jan-04 16:08 
GeneralA little bug :P PinsussXuewu Liu4-Jan-04 16:07 
GeneralAlso Patented Pinmembercompiler25-Nov-03 12:25 
GeneralRe: Also Patented PinmemberJubjub27-May-04 14:04 
GeneralRe: Also Patented Pinmemberdecompiler10-Aug-04 13:46 
GeneralBackground Color of Controls PinmemberMephisto18713-Oct-03 0:53 
GeneralDialog box implementation PinmemberModar4-May-03 8:02 
GeneralRe: Dialog box implementation PinmemberGrbFhg17-Aug-03 21:59 
Generallots of flicker PinmemberTodd Smith5-Mar-02 12:57 
GeneralContext menu bug PinmemberPaul Bludov10-Feb-02 23:17 
GeneralRe: Context menu bug PinmemberBjoern Graf1-Mar-02 11:23 
GeneralRe: Context menu bug PinmemberPallium3-Apr-07 14:23 
Generalok PinmemberRamon Smits14-Sep-01 11:47 
GeneralRe: ok PinmemberBjoern Graf1-Oct-01 3:52 
GeneralGreat time saving... PinmemberPaul Selormey3-Sep-01 18:35 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Mobile
Web03 | 2.8.140415.2 | Last Updated 5 Mar 2002
Article Copyright 2001 by Bjoern Graf
Everything else Copyright © CodeProject, 1999-2014
Terms of Use
Layout: fixed | fluid