MFC 鼠标悬停在控件上,显示提示信息
1.鼠标悬停在控件上,显示提示信息
其中,Text Control控件需要把通知选项设为true:
private:
CToolTipCtrl m_Ttc; //鼠标悬停提示
void SetToolTipsMsgMap(); //鼠标悬停提示
BOOL PreTranslateMessage(MSG* pMsg);//处理键盘和鼠标消息
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");
}
原文地址:https://blog.csdn.net/qq_35831134/article/details/143705434
免责声明:本站文章内容转载自网络资源,如本站内容侵犯了原著者的合法权益,可联系本站删除。更多内容请关注自学内容网(zxcms.com)!