It can contain multiple views, slides up and down when you click on the header controls and allows you to scroll the views when the button pane is too small to fit all the buttons.
Peeking (with the SPY++ utility) on how the real MS Access 2000 control was built, it almost brought tears to my eyes seeing how easily such a seemingly advanced control is constructed.
The control is actually a ReBar
control, with one or more
views embedded. The views are built from Pager
controls and
embedded ToolBar
controls.
While the ReBar control's gripper-bars are custom drawn to look like header-buttons,
the embedded ToolBar control handles all the button painting and message notifications.
It's actually that simple...
How to use it
The control is designed to be used in a view - and not particular for placement in a dialog.First you need to remember to initialize the Common Control Window classes with the...
ICC_COOL_CLASSES
ICC_BAR_CLASSES
ICC_PAGESCROLLER_CLASS
flags in the AtlInitCommonControls()
call.
Then add this reflection macro to the parent window's message map:
BEGIN_MSG_MAP(CMainFrame)
...
REFLECT_NOTIFICATIONS()
END_MSG_MAP()
Next - 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 "AccessBar.h"
class CMyView :
public CAccessBarImpl<CMyView>
{
public:
typedef CAccessBarImpl<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);
InsertBand(0, _T("Forums"), IDR_BAND1);
InsertBand(1, _T("Test"), IDR_BAND2);
InsertBand(2, _T("Favorites"), IDR_BAND3);
b = TRUE;
return lRes;
}
};
Finally, create 3 toolbars named
IDR_BAND1
, IDR_BAND2
and IDR_BAND3
.
Use the MSVC++ resource editor to create the toolbars; exactly
like the default IDR_MAINFRAME
toolbar.
When adding text to the buttons, format the prompt string as usual:
"Bla bla bla \n Command Text"
When you click on an item, you'll receive a WM_COMMAND
notification in the parent window just as if you had hit a menu item.
Source Code Dependencies
Microsoft Visual C++ 6.0Microsoft WTL 7.0 Library
See Also
The similar MS Outlook Bar controlDownload Files
![]() | Source Code (6 Kb) |