I have a window application (win32 API) in visual C++ in which I have to add tool tips to the control button. Can any one help me out in achieving the above task? Thanks in advance.
From within the designer: 1) From the ToolBox, drop a ToolTip control to your form. 2) Check the properties of this toolTip1 object to make sure Active is set to true. 3) Click on your button, and in its Property page, set the ToolTip on toolTip1 entry.
Set a ToolTip in the designer In Visual Studio, add a ToolTip component to the form. Select the control that will display the ToolTip, or add it to the form. In the Properties window, set the ToolTip on ToolTip1 value to an appropriate string of text.
Basic Tooltip HTML: Use a container element (like <div>) and add the "tooltip" class to it. When the user mouse over this <div>, it will show the tooltip text. The tooltip text is placed inside an inline element (like <span>) with class="tooltiptext" .
Drag the ToolTip control from the Toolbox, onto the form. Select the properties of the control you want the tool tip to appear on. Find the property 'ToolTip on toolTip1' (the name may not be toolTip1 if you changed it's default name). Set the text of the property to the tool tip text you would like to display.
If you don't use MFC classes see About Tooltip Controls
Here is an example using CToolTipCtrl class,
// Init a tooltip window
m_ToolTipCtrl = new CToolTipCtrl;
m_ToolTipCtrl->Create( this ); // 'this', usually a CDialog window
m_ToolTipCtrl->SetMaxTipWidth( 300 ); // if you need multiline messages
m_ToolTipCtrl->SetTipBkColor( 0x000000 );
m_ToolTipCtrl->SetTipTextColor( 0xe0e0d0 );
// Attach a CListBox control (we can attach many controls)
m_ToolTipCtrl->AddTool( plstBox, "Hey, i am a tooltip message!" );
// ...
// (*) We must use the following in order to use tooltips (MFC 4.0 and later versions)
BOOL MyDialog::PreTranslateMessage(MSG* pMsg)
{
if (NULL != m_ToolTipCtrl)
m_ToolTipCtrl->RelayEvent(pMsg); // <- listen mouse messages!
return CDialog::PreTranslateMessage(pMsg);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With