如何在动态创建的CMFCToolbar的工具提示中添加描述? [英] How to add description in dynamically created CMFCToolbar's ToolTip?
问题描述
CMFCToolbar继承了EnableToolTip函数,如果开发人员动态创建工具栏并且未在资源中添加说明和标题,则该函数对开发人员无济于事. 我对CMFCToolBar进行了扩展,并编写了一个函数:
The CMFCToolbar Inherits the function EnableToolTip which does not help the developer if he is creating the toolbar dynamically and not adding the Description and title in resource. I made an extension for CMFCToolBar and wrote a function :
BOOL CMFCToolBarEx::OnNeedTipText(UINT /*id*/, NMHDR* pNMH, LRESULT* /*pResult*/)
{
TOOLTIPTEXT *pTTT = (TOOLTIPTEXT *)pNMH;
// UINT nID = static_cast<int>(pNMH->idFrom);
CString strTip = _T("");
CPoint point;
::GetCursorPos(&point);
ScreenToClient(&point);
INT_PTR nHit = ((CMFCToolBar*)this)->HitTest(point);
if(nHit == -1)
return FALSE;
CMFCToolBarButton* pButton = GetButton((int)nHit);
strTip = pButton->m_strText;
_tcscpy(pTTT->lpszText , strTip.GetBuffer(0));
return TRUE;
}
在cmfctoolbar按钮中显示工具提示.
to show tooltip in cmfctoolbar button.
cmfctoolbar按钮没有参数,也没有设置描述的功能.构造函数采用如下参数:
The cmfctoolbar button takes no parameter and has no function to set description. The constructor takes parameter like :
pToolBarButton = new CMFCToolBarButton(nId, nIconIndex, lpszText);
如果我为参数lpszText设置了标题,则只会显示工具提示像这样
If I set the parameter lpszText with title only the tooltip appears like this
我需要在此工具栏中添加说明并查看它像这样可以建议一种更好的方法
I need to add description to this toolbar and view it like this if anyone can suggest a better way to do it
推荐答案
任何人在寻找答案.在这里,您只需添加
Anyone looking for answer. Here you go just add
CTooltipManager::SetTooltipText((TOOLINFO*) pTTT, m_pToolTip, AFX_TOOLTIP_TYPE_TOOLBAR, strTip, strDescr);
您覆盖的onneedtiptext函数.
to your overridden onneedtiptext function.
这篇关于如何在动态创建的CMFCToolbar的工具提示中添加描述?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!