在PreTranslateMessage中处理mouse move的消息,解决Picture Control设置notify为true之后与对话框OnMouseMove冲突的问题
来源:互联网 发布:java 1.6 32位下载 编辑:程序博客网 时间:2024/06/06 06:45
在PreTranslateMessage中处理mouse move的消息,解决Picture Control设置notify为true之后与对话框OnMouseMove冲突的问题
(注Picture Control的notify属性设置为true是为了使该控件响应点击等事件)
MFC中 监听OnMouseMove,当鼠标在Picture Control控件对应的rect区域时,更换Picture Control控件中显示的图片,但是当Picture Control控件的notify属性设置为true时,OnMouseMove中判断鼠标是否在Picture Control控件的rect区域不会响应,即这时候想实现Picture Control控件获取鼠标焦点时展示不同的视觉效果会失败。
最后解决办法是,把判断鼠标是否位于Picture Control控件的rect区域这个过程放到PreTranslateMessage处理。即如下的代码:
BOOL CExampleSixDlg::PreTranslateMessage(MSG *pMsg){//解决picture control的notify为true时与对话框mouse move时间冲突的问题。if (pMsg->message == WM_MOUSEMOVE){CRect rect;GetDlgItem(IDC_STATIC_PICTURE)->GetWindowRect(&rect);//获取控件坐标 相对于屏幕左上角CPoint pt;GetCursorPos(&pt);//获取光标在屏幕坐标中的位置 if (rect.PtInRect(pt)){//在control区域内,提示信息,更换图片等 m_button.SetWindowText(_T("focus"));//GetDlgItem(IDC_PICTURE_TEST)->SetIcon(m_tIcon,TRUE);//加载png图片CStatic *pwd = (CStatic *)GetDlgItem(IDC_STATIC_PICTURE);CImage img;img.Load(_T("./res/test2.png"));HBITMAP hBmp = img.Detach();pwd->SetBitmap(hBmp);//加载图标iconpwd = (CStatic *)GetDlgItem(IDC_PICTURE_TEST);pwd->SetIcon(m_hIcon);}else{//不在control区域内,提示信息,更换图片等 m_button.SetWindowText(_T("focus not"));//GetDlgItem(IDC_PICTURE_TEST)->SetIcon(m_hIcon,TRUE);//加载png图片CStatic *pwd = (CStatic *)GetDlgItem(IDC_STATIC_PICTURE);CImage img;img.Load(_T("./res/test1.png"));HBITMAP hBmp = img.Detach();pwd->SetBitmap(hBmp);//加载图标iconpwd = (CStatic *)GetDlgItem(IDC_PICTURE_TEST);pwd->SetIcon(m_tIcon);} }return CDialog::PreTranslateMessage(pMsg);}
0 0
- 在PreTranslateMessage中处理mouse move的消息,解决Picture Control设置notify为true之后与对话框OnMouseMove冲突的问题
- 教你在mfc中 怎么得到和处理 控件的消息,比如 cbutton 的 onmousemove
- 在picture control 里贴图的问题
- 在对话框中使用picture control显示静态图片的方法
- VC6.0中对消息的特殊处理--PreTranslateMessage说明
- VC6.0中对消息的特殊处理--PreTranslateMessage说明
- Android 中 onTouch 和OnClick 冲突的处理(onTouchEvent返回true时与onclick冲突)
- MFC中在picture control中显示图像的方法
- 在对话框picture control中利用opengl进行绘图
- 在对话框picture control中利用opengl进行绘图
- 关于在Picture Control中绘制 BMP JPG 的方法
- picture control 设置为图片大小
- win32编程中对话框处理函数最后的返回值为TRUE导致了程序异常
- MFC中的PreTranslateMessage 的处理,意思就是在过滤之前的一些消息的处理
- notify-listview-的消息处理
- 在MFC中手动添加消息处理函数PreTranslateMessage
- 在MFC中手动添加消息处理函数PreTranslateMessage
- [ MFC ] 对话框动态控件的创建 在Picture Control控件上显示图片 [大三TJB_708]
- 阿里巴巴分布式数据库服务DRDS研发历程
- 学习心情 随笔。。。。
- 使用位逻辑运算实现位向量,并实现大数据排序
- 4-9 二叉树的遍历 (25分)
- 广播BroadcastReceiver
- 在PreTranslateMessage中处理mouse move的消息,解决Picture Control设置notify为true之后与对话框OnMouseMove冲突的问题
- 响应式布局
- opencv:视频处理
- 杨辉三角输出
- 网址
- 算法训练 未名湖边的烦恼
- Mysql的介绍和安装
- 1045.Favorite Color Stripe (30)
- [BZOJ2242][SDOI2011][BSGS][拓展欧几里得]计算器