Click here to Skip to main content
Click here to Skip to main content
Go to top

Button with ToolTip and/or bitmap resource

, 14 Oct 2001
Rate this:
Please Sign up or sign in to vote.
A simple way to have tooltip and a 4 state button using a bitmap resource
<!-- Download Links --> <!-- Article image -->

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

Share

About the Author

Jean-Louis Guenego

United States United States
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.

Comments and Discussions

 
GeneralUsing CWnd::EnableToolTips() [modified] PinmemberSnakefoot18-Mar-09 0:55 
Generalno tooltip in cdialogbar Pinmembersonic2917-Aug-05 21:46 
GeneralExample causes memory leaks PinmemberOgi27-Aug-04 0:03 
Generals Using this Button in Dialog Bar Pinmemberiffi99214-Jan-04 2:00 
QuestionCan we apply bitmap buttons at runtime? Pinmemberc_anands28-Feb-03 0:26 
GeneralToolTipButton in modeless Dialogs Pinmemberjensieleinchen12-Jun-02 2:10 
GeneralRe: ToolTipButton in modeless Dialogs (in any non CFrameWnd container...) Pinmemberfrankym30-Oct-03 10:12 
GeneralRe: ToolTipButton in modeless Dialogs (in any non CFrameWnd container...) Pinmemberhroenick6-Jan-05 8:52 
GeneralRe: ToolTipButton in modeless Dialogs (in any non CFrameWnd container...) Pinmemberfrankym7-Jan-05 11:36 
GeneralRe: ToolTipButton in modeless Dialogs (in any non CFrameWnd container...) Pinmemberhroenick7-Jan-05 11:52 
GeneralRe: ToolTipButton in modeless Dialogs (in any non CFrameWnd container...) PinmemberJPMSODENA9-May-07 22:31 
GeneralRe: ToolTipButton in modeless Dialogs (in any non CFrameWnd container...) PinmemberHieupv20006-Oct-08 1:34 
GeneralProblems PinmemberYasmin26-Mar-02 6:49 
GeneralRe: Problems [modified] Pinmember__sephiroth14-Sep-06 4:41 

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

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

| Advertise | Privacy | Mobile
Web02 | 2.8.140926.1 | Last Updated 15 Oct 2001
Article Copyright 2001 by Jean-Louis Guenego
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid