Click here to Skip to main content
13,900,817 members
Click here to Skip to main content
Add your own
alternative version


29 bookmarked
Posted 24 Aug 2007
Licenced CPOL

The Ultimate Toolbox HyperBar

, 25 Aug 2007
Rate this:
Please Sign up or sign in to vote.
The COXHyperBar control is an MFC control which will give the floating toolbar look seen in the Microsoft Expression 'Hyperbar' sample

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, COXHyperbar, COXHyperbarOverlay and COXHyperbarRender. Add the .cpp and .h files for these three classes to your project. Now change any instance of CToolbar to 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:

CImageList imageList;
CBitmap bitmap;

imageList.Create(90, 90, ILC_COLOR24|ILC_MASK, 8, 1);

imageList.Add(&bitmap, RGB(255,0,255));

imageList.Add(&bitmap, RGB(255,0,255));

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:

AfxGetMainWnd()->SendMessage(WM_NCACTIVATE, TRUE);

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.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

The Ultimate Toolbox
Web Developer
Canada Canada
In January 2005, David Cunningham and Chris Maunder created, a new group dedicated to the continued development, support and growth of Dundas Software’s award winning line of MFC, C++ and ActiveX control products.

Ultimate Grid for MFC, Ultimate Toolbox for MFC, and Ultimate TCP/IP have been stalwarts of C++/MFC development for a decade. Thousands of developers have used these products to speed their time to market, improve the quality of their finished products, and enhance the reliability and flexibility of their software.
Group type: Organisation

459 members

You may also be interested in...

Comments and Discussions

GeneralAnimation stopped working! Pin
Nader Michael27-Dec-08 11:18
memberNader Michael27-Dec-08 11:18 
GeneralRe: Animation stopped working! Pin
Tim Deveaux6-Jan-09 12:25
memberTim Deveaux6-Jan-09 12:25 
QuestionTooltips for HyperBar [modified] Pin
D G McKay26-Oct-07 5:12
memberD G McKay26-Oct-07 5:12 

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

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

Permalink | Advertise | Privacy | Cookies | Terms of Use | Mobile
Web06 | 2.8.190306.1 | Last Updated 25 Aug 2007
Article Copyright 2007 by The Ultimate Toolbox
Everything else Copyright © CodeProject, 1999-2019
Layout: fixed | fluid