//在CMainFrame类中添加处理虚函数
//virtual BOOL OnMenuButtonToolHitTest(CMFCToolBarButton* pButton, TOOLINFO* pTI);
// MSDN: Override this method if you want to provide a tooltip information about a specific menu item.
BOOL CMainFrame::OnMenuButtonToolHitTest (CMFCToolBarButton* pButton, TOOLINFO* pTI)
{
ASSERT_VALID (pButton);
ASSERT (pTI != NULL);
if (pButton->m_nID == 0 || pButton->m_nID == (UINT)-1)
{
return FALSE;
}
CString strText = pButton->m_strText;
strText.Remove (_T('&'));
if (strText.IsEmpty ())
{
return FALSE;
}
if (pTI)
{
pTI->lpszText = (LPTSTR) ::calloc ((strText.GetLength () + 1), sizeof (TCHAR));
if (pTI->lpszText)
{
lstrcpy (pTI->lpszText, strText);
}
}
return TRUE;
}
// 效果如下所示:
![](http://hi.csdn.net/attachment/201109/2/0_1314923752KcYZ.gif)