Dave's Brain

Browse - Programming Tips - How do I add tooltips to a regular button?

Date: 2008sep8
Framework: 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 CMyDialog::PreTranslateMessage(MSG* pMsg) { m_ButtonToolTip.RelayEvent(pMsg); return CDialog::PreTranslateMessage(pMsg); }

Add a comment

Sign in to add a comment
Copyright © 2008-2018, 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.