CCustomizableToolBar - A toolbar that can be customized. This class is the most simple implementation of a customizable toolbar using MFC. You can just replace the existing reference of CToolbar to CCustomizableToolBar and your application has a customizable toolbar! As an extra feature I also enabled this class for hot button support (like Internet Explorer).
Usage: Create the toolbar just a normal:
if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) || !m_wndToolBar.LoadToolBar(IDR_MAINFRAME)) { TRACE0("Failed to create toolbar\n"); return -1; // fail to create }
Enable hot button support:
SetImages(UINT nResourceNormal, UINT nResourceHot, UINT nResourceDisabled , BOOL bLargeImages)
where: nResourceNormal: resource id for normal state nResourceHot: resource id for hot state (mouse over) nResourceDisabled: resource id for disabled state bLargeImages: TRUE = the images are for large buttons, FALSE = the images are for small buttons,
so the code will look something like this:
m_wndToolBar.SetImages(IDB_COLD_SMALL, IDB_HOT_SMALL, IDB_DISABLED_SMALL, FALSE); m_wndToolBar.SetImages(IDB_COLD_LARGE, IDB_HOT_LARGE, IDB_DISABLED_LARGE, TRUE);
Download example executable
Download source code This class is part of the Pablo Software Solutions MFC Extension Package - Controls Edition
|