Click here to Skip to main content
15,867,686 members
Articles / Desktop Programming / MFC
Article

The Ultimate Toolbox HyperBar

Rate me:
Please Sign up or sign in to vote.
4.40/5 (4 votes)
25 Aug 2007CPOL3 min read 40.1K   874   29   3
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.

Contents

Overview

Image 1

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:

Image 2

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:

C++
CImageList imageList;
CBitmap bitmap;

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

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

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

m_wndToolBar.SendMessage(TB_SETIMAGELIST, 0, (LPARAM)imageList.m_hImageList);
imageList.Detach();

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:

C++
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.

History

Initial CodeProject release August 2007.

License

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


Written By
Web Developer
Canada Canada
In January 2005, David Cunningham and Chris Maunder created TheUltimateToolbox.com, 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.
This is a Organisation

476 members

Comments and Discussions

 
GeneralAnimation stopped working! Pin
Nader Michael27-Dec-08 11:18
Nader Michael27-Dec-08 11:18 
GeneralRe: Animation stopped working! Pin
Tim Deveaux6-Jan-09 12:25
Tim Deveaux6-Jan-09 12:25 
QuestionTooltips for HyperBar [modified] Pin
D G McKay26-Oct-07 5:12
D 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.