Display a tool-tip!!!

Dear All,

I want to know how to display a tooltip when I have moved the mouse over a button.
The button control is placed at the dialog.....and this dialog will be used at the CFormView class......

How can I impelemnt a tooltip in this suitation?

Thanks!!!
ee_lcpaaAsked:
Who is Participating?
 
VCGuruConnect With a Mentor Commented:
class CMyFormView:public CFormView
{
....
CButton m_button;
//use class wizard to add m_button
....
CToolTipCtrl m_ToolTip;
};

in the .cpp
Override PreTranslateMessage

BOOL CMyFormView::PreTranslateMessage(...)
{
m_ToolTip.RelayEvent(pMsg);
return CFormView::PreTranslate...
}

void CMyFormView::OnInitialUpdate()
{
...
if(!m_ToolTip.Create(this))
{
//error
return;
}
m_ToolTip.AddTool(&m_button,IDC_BUTTON);
//where IDC_BUTTON is the ID of the button

m_ToolTip.Activate(TRUE);
}

That's it.
0
 
VCGuruCommented:
oops messed up...
In the above answer IDC_BUTTON is NOT THE ID of the button.

What you have to do is use the resource editor to define string resources for each control. If my button needs a tooltip "MyButton" then IDS_MYTOOL would be defined as "MyButton". The AddTool function in the above answer would be.

m_ToolTip.AddTool(&m_button,IDS_MYTOOL );

Sorry for the inconvinience
0
All Courses

From novice to tech pro — start learning today.