Dave's Brain

Browse - programming tips - mfc tooltips for a regular button

Date: 2008sep8
Platform: MFC
Language: C/C++

Q.  How do I add tooltips to a regular button?

A.  Use the CToolTipCtrl class.  For button in a toolbar there is a
different way.

Add this to your dialog:

	CToolTipCtrl	m_ButtonToolTip;

In InitDialog() do:

	m_ButtonToolTip.Create(this);
	m_ButtonToolTip.AddTool(&m_OK, "OK.  Save your updates.");
	m_ButtonToolTip.Activate(TRUE);

Handle PreTranslateMessage this way:

	BOOL CAuthorDlg::PreTranslateMessage(MSG* pMsg) 
	{
		m_ButtonToolTip.RelayEvent(pMsg);
		return CDialog::PreTranslateMessage(pMsg);
	}
What this info useful to you? You can donate to say thanks

Add a comment

Sign in to add a comment
Copyright © 2008-2012, dave - Code samples on Dave's Brain is licensed under the Creative Commons Attribution 2.5 License. However other material, including English text has all rights reserved.
Advertisements: