Visit the Ultimate Toolbox main page for an overview and configuration guide to the Ultimate Toolbox library.
Source code and project files for this sample are included in the samples\gui\HyperbarDemo directory of the sample projects download.
The hyperbar control is an MFC control, derived principally from
CToolbar, which can be added to any project and which will give the floating toolbar look seen in the Microsoft Expression 'Hyperbar' sample. The control has been designed to be easy to add to any existing project. Simply change the type of your existing toolbar to
COXHyperbar, and add the 3 required classes to your project. The degree of zoom effect is exposed as a parameter, and the framework has been designed to allow any desired background color, pattern or image.
The overall effect adds .NET 3.0 pizzaz to any MFC application that has a toolbar.
Using the Hyperbar
There are three classes used by the hyperbar,
COXHyperbarRender. Add the .cpp and .h files for these three classes to your project. Now change any instance of
COXHyperbar, and you will get the default functionality, which looks something like this:
The problem with this is simply that the images passed to a toolbar tend to be the correct size for the toolbar, so as soon as we start to stretch these images, they start to look a little jagged. To get around this, simply create larger images and replace the image list for the toolbar, so that the end result is not drawn at greater than 1:1 resolution. First add your images to your project resources, then load them with code along these lines:
imageList.Create(90, 90, ILC_COLOR24|ILC_MASK, 8, 1);
m_wndToolBar.SendMessage(TB_SETIMAGELIST, 0, (LPARAM)imageList.m_hImageList);
Note the need to detach the MFC wrappers from the imagelist and bitmaps, so they are not destroyed by a destructor.
The degree of zoom is set by a static parameter,
COXHyperBarRender::m_Focus. This is a double, ideally it should be set to values < 0.4, it should certainly not be set to values <= 0.
Considerations of Focus
The hyperbar will not animate unless the application has focus, however, if your application has any modeless windows, then they should use the following code:
This code should be called whenever a modeless window gains the input focus ( the demo illustrates this ), because otherwise moving the mouse over the hyperbar will create a screenshot of the unfocused title bar, the bar will send this message, and so the title bar will be drawn unfocused from the screenshot taken by the hyperbar, and focused along the rest of its length.
Alternatively, you can derive your
CFrameWnd class from
COXHyperFrameWnd, which will then handle this for you for all child windows. This approach causes some double up of code. Requiring this base class would have simplified the code somewhat, but the result would not be compatible with projects which already choose a new base class. For example, to provide the skinning framework.
Initial CodeProject release August 2007.