Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add a tool tip to control in window application (win32 API) using Visual C++ 2008

Tags:

visual-c++

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.

like image 213
Ravi shankar Avatar asked Dec 02 '09 10:12

Ravi shankar


People also ask

How do I add ToolTip in Winforms?

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.

How do I add a ToolTip in Visual Studio?

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.

How do you set a ToolTip?

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" .

How do I show ToolTip in Windows?

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.


1 Answers

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);
}
like image 148
Nick Dandoulakis Avatar answered Jan 02 '23 11:01

Nick Dandoulakis



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!