
Introduction
This article is inspired from the HoverButton found at CodeProject.
Thanks to its author Niek Albers.
You should read it before what follow.
With the two classes presented here, you can easily use button controls which have :
- tooltip control (except when disabled)
- possible bitmap representation with 4 states like
CBitmapButton (up, down, focused, disabled)
The difference with the HoverButton is that :
- we have the possibility to DISABLE the button.
- we can use the tooltip and bitmap functionalities separately
There are two classes involved here:
CToolTipButton : it is a CButton with only the tooltip functionality
CToolTipRessourceButton : it is a CToolTipButton with bitmap representation (4 states)
How to use it (tooltip functionality only)
If you want only the tooltip functionality, Follow this steps :
- First you need the 2 following files:
- ToolTipButton.cpp
- ToolTipButton.h
Insert these 2 files in your project.
- Include in the dialog where you want to use the buttons
#include "ToolTipButton.h"
- With the ClassWizard (menu Member Variable), add a control attributes for the button.
- Modify in the code the button class control
CButton to CToolTipButton.
- In the method
OnInitDialog(), add the following code :
m_ToolTipButton.SetToolTipText(new CString("hello !!!"));
and that should be it
How to use it (all the functionality)
- First you need the 4 following files :
- ToolTipButton.cpp
- ToolTipButton.h
- ToolTipRessourceButton.cpp
- ToolTipRessourceButton.h
Insert these 4 files in your project.
- Include in the dialog where you want to use the buttons
#include "ToolTipRessourceButton.h"
- Make a bitmap resource with the 4 states like this one :

- Add the bitmap in the resources (import)
- With the ClassWizard (menu Member Variable), add a control attributes for the button.
- Modify in the code the button class control
CButton to CToolTipRessourceButton.
- In the method
OnInitDialog(), add the following code :
m_ToolTipRessourceButton.LoadBitmap(IDB_TOOLTIP_RESSOURCE_BUTTON);
m_ToolTipRessourceButton.SetToolTipText(new CString("hello !!!"));
and that should be it.
Professor in physics at Universty of Marne-La-Vallee (Paris, France).
Ex-Consultant (in Telecom) for Cap Gemini America at Atherton (Silicon Valley, San Francisco, CA USA).
I like very much coding.