tags:

views:

27

answers:

1

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.

+1  A: 

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);
}
Nick D
I am not using MFC, but you link sloved my problem thanks for you reply.
Ravi shankar