The control can contain multiple views, slides up and down when you click on the header bars, and allows you to add title icons and custom expand/collapse buttons. Several style flags can be used to customize how the panels behave and are painted. Specifically you can also enjoy a "flat" look - like the non-themed version of Windows XP.
When you click on a panel, you'll receive a WM_COMMAND
notification in the parent window telling you that a panel is being
expanded or collapsed. Panels slide up and down using animation, however
this feature can be turned off.
The control also supports an ownerdrawn style that allows you to catch
WM_DRAWITEM
messages to paint your own button graphics.
For performance reasons, the control internally renders and stores the button graphics in a bitmap, so it can be blitted to the screen as quickly as possible. To prevent flicker, a memory DC is used during the paint sequence.
How to use it
The control is designed to be used in a view - and not particular for placement in a dialog. Assuming that the project is built with a splitter style layout, or at least that the control will be placed in a separate view - create a view class looking like this...#include "CollapsiblePanel.h"
class CMyView :
public CCollapsiblePanelImpl<CMyView>
{
public:
typedef CCollapsiblePanelImpl<CMyView> parentClass;
BOOL PreTranslateMessage(MSG* pMsg)
{
pMsg;
return FALSE;
}
BEGIN_MSG_MAP(CMyView)
MESSAGE_HANDLER(WM_CREATE, OnCreate)
CHAIN_MSG_MAP( parentClass )
END_MSG_MAP()
LRESULT OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& b)
{
LRESULT lRes = parentClass::OnCreate(uMsg, wParam, lParam, b);
...
InsertItem(m_view1, _T("File and Folder Tasks"));
InsertItem(m_view2, _T("Details"));
InsertItem(m_view3, _T("Links"));
b = TRUE;
return lRes;
}
};
Finally, create the view dialogs. Remove all border styles, captions, and make them
CHILD
forms. You must also add the "Clip Siblings" style
(the WS_CLIPSIBLINGS
style flag) because of rendering problems in Windows.
Source Code Dependencies
Microsoft Visual C++ 6.0Microsoft WTL 7.0 Library
See Also
A nice MS Outlook Bar controlUseful Links
Chris Haarmeijer's extended versionDownload Files
![]() | Source Code (38 Kb) |