Click here to Skip to main content
Click here to Skip to main content

Button with ToolTip and/or bitmap resource

By , 14 Oct 2001
 

Sample Image - ToolTipRessourceButton.gif

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 :

  1. tooltip control (except when disabled)
  2. possible bitmap representation with 4 states like CBitmapButton (up, down, focused, disabled)

The difference with the HoverButton is that :

  1. we have the possibility to DISABLE the button.
  2. we can use the tooltip and bitmap functionalities separately

There are two classes involved here:

  1. CToolTipButton : it is a CButton with only the tooltip functionality
  2. 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 :

  1. First you need the 2 following files:

    • ToolTipButton.cpp
    • ToolTipButton.h

    Insert these 2 files in your project.

  2. Include in the dialog where you want to use the buttons
    #include "ToolTipButton.h"
    
  3. With the ClassWizard (menu Member Variable), add a control attributes for the button.

  4. Modify in the code the button class control CButton to CToolTipButton.

  5. In the method OnInitDialog(), add the following code :
    	// TODO: Add extra initialization here
    	// The only code to setup the button
    	// IDB_TOOLTIP_RESSOURCE_BUTTON is the bitmap resource ID
    	m_ToolTipButton.SetToolTipText(new CString("hello !!!"));
    

and that should be it

How to use it (all the functionality)

  1. First you need the 4 following files :

    1. ToolTipButton.cpp
    2. ToolTipButton.h
    3. ToolTipRessourceButton.cpp
    4. ToolTipRessourceButton.h

    Insert these 4 files in your project.

  2. Include in the dialog where you want to use the buttons

    #include "ToolTipRessourceButton.h"
    
  3. Make a bitmap resource with the 4 states like this one :

    Bitmap ressource

  4. Add the bitmap in the resources (import)

  5. With the ClassWizard (menu Member Variable), add a control attributes for the button.

  6. Modify in the code the button class control CButton to CToolTipRessourceButton.
  7. In the method OnInitDialog(), add the following code :
    	// TODO: Add extra initialization here
    	// The only code to setup the button
    	// IDB_TOOLTIP_RESSOURCE_BUTTON is the bitmap resource ID
    	m_ToolTipRessourceButton.LoadBitmap(IDB_TOOLTIP_RESSOURCE_BUTTON);
    	m_ToolTipRessourceButton.SetToolTipText(new CString("hello !!!"));
    

and that should be it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

Jean-Louis Guenego
United States United States
Member
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.

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
Hint: For improved responsiveness ensure Javascript is enabled and choose 'Normal' from the Layout dropdown and hit 'Update'.
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
Generals Using this Button in Dialog Barmemberiffi99214 Jan '04 - 2:00 

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

Permalink | Advertise | Privacy | Mobile
Web04 | 2.6.130516.1 | Last Updated 15 Oct 2001
Article Copyright 2001 by Jean-Louis Guenego
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid