MFC 鼠标悬停在控件上,显示提示信息

1.鼠标悬停在控件上,显示提示信息
其中,Text Control控件需要把通知选项设为true:
cpp 复制代码
private:
	CToolTipCtrl m_Ttc;                                 //鼠标悬停提示 
	void SetToolTipsMsgMap();                           //鼠标悬停提示
	BOOL PreTranslateMessage(MSG* pMsg);				//处理键盘和鼠标消息
cpp 复制代码
BOOL Settings::OnInitDialog()
{
	CDialogEx::OnInitDialog();

	EnableToolTips(true);     //使能悬停提示
	m_Ttc.Create(this);       //此窗口悬停提示
	SetToolTipsMsgMap();      //鼠标悬停提示
}
//处理键盘和鼠标消息
BOOL Settings::PreTranslateMessage(MSG* pMsg)
{
	CString cstrMessageOut;
	m_Ttc.RelayEvent(pMsg);     //鼠标悬停提示 
	return CDialog::PreTranslateMessage(pMsg);
}
//鼠标悬停提示
void Settings::DoDataExchange(CDataExchange* pDX)
{
	CDialogEx::DoDataExchange(pDX);
	m_Ttc.AddTool(GetDlgItem(IDC_STATIC), L"--");
	m_Ttc.AddTool(GetDlgItem(IDC_Combobox_sortMode), L"--");
	m_Ttc.AddTool(GetDlgItem(IDC_AllBuffer1),	  L"悬停提示1");
	m_Ttc.AddTool(GetDlgItem(IDC_Static_Number1), L"悬停提示2");
	m_Ttc.AddTool(GetDlgItem(IDC_Static_Number2), L"悬停提示3");
}
相关推荐
博笙困了1 天前
AcWing学习——双指针算法
c++·算法
感哥1 天前
C++ 指针和引用
c++
感哥2 天前
C++ 多态
c++
沐怡旸2 天前
【底层机制】std::string 解决的痛点?是什么?怎么实现的?怎么正确用?
c++·面试
River4162 天前
Javer 学 c++(十三):引用篇
c++·后端
感哥2 天前
C++ std::set
c++
侃侃_天下2 天前
最终的信号类
开发语言·c++·算法
博笙困了2 天前
AcWing学习——差分
c++·算法
青草地溪水旁2 天前
设计模式(C++)详解—抽象工厂模式 (Abstract Factory)(2)
c++·设计模式·抽象工厂模式
青草地溪水旁2 天前
设计模式(C++)详解—抽象工厂模式 (Abstract Factory)(1)
c++·设计模式·抽象工厂模式