
2、在子对话框中也定义变量 CString,或者一个ListBox的数据变量
3、在子对话框的Dlg类中,响应ListBox的鼠标双击消息映射函数,在函数中将子Dlg的CString值传给主对话框CString
4、在主对话框的button的消息响应函数中,主动刷新picturecontrol加载CString图片路径
首先在对话框的头文件中加入初始化语句:private:下,加入:CToolTipCtrl m_Mytip然后在初始化对话框函数(OnInitDialog)中加入:
m_Mytip.Create(this)
m_Mytip.AddTool( GetDlgItem(IDC_LIST), "你想要添加的提示信息" )//IDC_BUTTON为你要添加提示信息的LISTBOX的ID
m_Mytip.SetDelayTime(200)//设置延迟
m_Mytip.SetTipTextColor( RGB(0,0,255) )//设置提示文本的颜色
m_Mytip.SetTipBkColor( RGB(255,255,255))//设置提示框的背景颜色
m_Mytip.Activate(TRUE)//设置是否启用提示
然后在类向导中添加PreTranslateMessage消息响应函数
BOOL CXXXDlg::PreTranslateMessage(MSG* pMsg)
{
// TODO: Add your specialized code here and/or call the base class
if(pMsg->message==WM_MOUSEMOVE /*&&pMsg->hwnd == GetDlgItem(IDC_BUTTON1)->GetSafeHwnd())*/)
m_Mytip.RelayEvent(pMsg)
return CDialog::PreTranslateMessage(pMsg)
}
注:如果要为多个按钮添加功能提示只需在
m_Mytip.AddTool( GetDlgItem(IDC_LIST), "你想要添加的提示信息" )
的下面再加上类似语句,如
m_Mytip.AddTool( GetDlgItem(IDC_LIST1), "你想要添加的提示信息1" )
m_Mytip.AddTool( GetDlgItem(IDC_LIST2), "你想要添加的提示信息2" )
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)