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");
}
相关推荐
C++ 老炮儿的技术栈2 小时前
volatile使用场景
linux·服务器·c语言·开发语言·c++
hz_zhangrl2 小时前
CCF-GESP 等级考试 2026年3月认证C++一级真题解析
开发语言·c++·gesp·gesp2026年3月·gespc++一级
Liu628882 小时前
C++中的工厂模式高级应用
开发语言·c++·算法
波特率1152003 小时前
const关键字与函数的重载
开发语言·c++·函数重载
干啥啥不行,秃头第一名3 小时前
C++20概念(Concepts)入门指南
开发语言·c++·算法
2301_807367194 小时前
C++中的解释器模式变体
开发语言·c++·算法
2301_819414306 小时前
C++与区块链智能合约
开发语言·c++·算法
不想看见4046 小时前
Valid Parentheses栈和队列--力扣101算法题解笔记
开发语言·数据结构·c++
老约家的可汗6 小时前
C/C++内存管理探秘:从内存分布到new/delete的底层原理
c语言·c++
天赐学c语言6 小时前
Linux - 应用层自定义协议与序列/反序列化
linux·服务器·网络·c++