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");
}
相关推荐
hPw0eKIqD20 小时前
C++ 模板参数推导问题小记(非推导上下文)
开发语言·c++
程序员爱德华20 小时前
Python与C++:异同点对比
c++·python
888CC++1 天前
C语言与C++的区别:从面向过程到面向对象
java·c语言·c++
Darkwanderor1 天前
Linux系统编程实战项目:模拟实现shell
linux·c++
himobrinehacken1 天前
揭秘Windows程序启动的神秘之旅
c++·安全
库玛西1 天前
C++ 运行时多态 :核心总结与原理图解
c语言·c++·笔记
Byron Loong1 天前
【C++】重定向是什么
开发语言·c++
hansang_IR1 天前
【题解】LC:Z 算法(Z Algorithm)
c++·算法·字符串
霍霍的袁1 天前
【C++】模板从入门到进阶(函数模板 + 类模板 + 特化 + 分离编译)
开发语言·c++·visual studio
海清河晏1111 天前
Qt 实战:信号与槽+事件系统
开发语言·c++·qt