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");
}
相关推荐
结衣结衣.12 分钟前
手把手教你实现文档搜索引擎
linux·c++·搜索引擎·开源·c++11
t***54419 分钟前
如何在 Dev-C++ 中切换编译器
java·开发语言·c++
大肥羊学校懒羊羊35 分钟前
完数与盈数的计算题解
数据结构·c++·算法
澈20736 分钟前
构造函数与析构函数完全指南
开发语言·c++
W230357657341 分钟前
C++ 高并发线程池实战(二):动态缓存线程池 + 调用者运行拒绝策略完整版实现
开发语言·c++·缓存
t***5441 小时前
如何在 Dev-C++ 中使用 Clang 编译器
开发语言·c++
cany10001 小时前
C++ - 智能指针
开发语言·c++
Emberone2 小时前
深入理解 C++ STL string:从接口使用到底层模拟实现
c++·stl
t***5442 小时前
如何在 Dev-C++ 中设置和使用 Clang 编译器
开发语言·c++
楼田莉子3 小时前
CMake学习:CMake语法
c++·后端·学习·软件构建