VC中怎样实现当鼠标移到某个按钮上时提示这个按钮是什么?

来源:百度知道 编辑:UC知道 时间:2024/05/26 14:04:20
当鼠标移动到某个按钮(ID)上时,出现一个小提示,提示这个按钮的名称是什么,该怎么弄?
提示信息时显示在鼠标的右下方的,而不是显示在状态栏上的。
-------------
m_tt.SetTitle(1,L"Title");//不要title可以删除
L 是什么意思?

工具栏按钮?

如按钮的“Prompt”属性
如关于的如下:
显示程序信息,版本号和版权\n关于

在类定义中添加变量说明:
class CWndYour:xxx
{
CToolTipCtrl m_tt;
}
在OnCreate中添加需要显示Tip的子窗口
CWndYour::OnCreate(....)
{
EnableToolTips(TRUE);
m_tt.Create(this);
m_tt.Activate(TRUE);
m_tt.SetTitle(1,"Title");//不要title可以删除
m_tt.SetDelayTime(150);

CWnd* pW=GetDlgItem(IDC_BUTTON1);//得到窗口指针
m_tooltip.AddTool(pW,"这是一个按钮");
}
重写 PreTranslateMessage(MSG* pMsg)添加代码
BOOL CWndYour::PreTranslateMessage(MSG* pMsg)
{
m_tt.RelayEvent(pMsg);
return CParentClass::PreTranslateMessage(pMsg);
}

这样当鼠标移动到相应BUTTON上时会显示出相应的ToolTip。
--------------------------
L就是使用UNICODE字符集。。这里不需要,是误笔