开发者

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

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 开发者_StackOverflow社区help me out in achieving the above task? Thanks in advance.


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);
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜