Click here to Skip to main content
15,885,244 members
Articles / Desktop Programming / MFC

Button with ToolTip and/or Bitmap Resource

Rate me:
Please Sign up or sign in to vote.
4.57/5 (8 votes)
14 Oct 20012 min read 173.8K   4.6K   54  
A simple way to have tooltip and a 4 state button using a bitmap resource
#if !defined(AFX_TOOLTIPBITMAPBUTTON_H__DFD18BA7_9BC4_11D5_8F75_0048546F01E7__INCLUDED_)
#define AFX_TOOLTIPBITMAPBUTTON_H__DFD18BA7_9BC4_11D5_8F75_0048546F01E7__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// ToolTipBitmapButton.h : header file
//

/////////////////////////////////////////////////////////////////////////////
// CToolTipButton window

//#define baseCToolTipButton CBitmapButton
#define baseCToolTipButton CButton
// if you do not want to profit of CBitmapButton, put simply CButton instead

// CToolTipRessourceButton by Jean-Louis GUENEGO
// Thanks to Niek Albers.
// A cool CButton with tooltips
class CToolTipButton : public baseCToolTipButton
{
// Construction
public:
	CToolTipButton();

// Attributes
public:

protected:
	CToolTipCtrl m_ToolTip;

// Operations
public:
	void SetToolTipText(CString* spText, BOOL bActivate = TRUE);
protected:
	void InitToolTip();

// Overrides
	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CToolTipButton)
	public:
	virtual BOOL PreTranslateMessage(MSG* pMsg);
	//}}AFX_VIRTUAL

// Implementation
public:
	virtual ~CToolTipButton();

	// Generated message map functions
protected:
	//{{AFX_MSG(CToolTipButton)
		// NOTE - the ClassWizard will add and remove member functions here.
	//}}AFX_MSG

	DECLARE_MESSAGE_MAP()
};

/////////////////////////////////////////////////////////////////////////////

//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_TOOLTIPBITMAPBUTTON_H__DFD18BA7_9BC4_11D5_8F75_0048546F01E7__INCLUDED_)

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.


Written By
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