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");
}
相关推荐
阿猿收手吧!11 分钟前
【C++】Ranges:彻底改变STL编程方式
开发语言·c++
Polaris北1 小时前
第二十三天打卡
c++
船神丿男人3 小时前
C++:STL string(一)
开发语言·c++
程序员zgh3 小时前
Linux 内存管理单元 MMU
linux·运维·服务器·c语言·开发语言·c++
Smart-Space3 小时前
将copilot键映射为右control - 参考powertoys实现
c++
Trouvaille ~3 小时前
【Linux】TCP协议基础与连接管理详解:从三次握手到四次挥手
linux·运维·服务器·网络·c++·网络协议·tcp/ip
想做功的洛伦兹力13 小时前
2026/2/12日打卡
开发语言·c++·算法
你撅嘴真丑3 小时前
蛇形填充数组 与 查找最接近的元素
数据结构·c++·算法
blackicexs4 小时前
第四周第四天
数据结构·c++·算法
知无不研4 小时前
c++的设计模式(常用)
c++·观察者模式·单例模式·设计模式·简单工厂模式