VC让鼠标指到按钮上变成手型
2016-11-27 21:52
260 查看
两种方法: 1、派生一个CButton类,然后重载OnSetCursor函数,在里面 使用SetCursor函数设置鼠标指针。 然后删除 return CButton::OnSetCursor(pWnd, nHITTest, message); 改成 return TRUE; 例如: BOOL CMyButton::OnSetCursor(CWnd* pWnd, UINT nHITTest, UINT message) { ::SetCursor(::LoadCursor(NULL, MAKEINTRESOURCE(IDC_HAND))); return TRUE; } 2、直接在程序里,响应WM_MOUSEMOVE消息,在里面判断鼠标指针是否指到了按钮上,是的话就用SetCursor函数设置鼠标指针,离开再设回以前的指针[cpp] view plain copy print?void CbpmDlg::OnMouseMove(UINT nFlags, CPoint point) { // TODO: 在此添加消息处理程序代码和/或调用默认值 CRect adbanerRect; CRect btnSelectPathRect; CRect btnStartRect; m_GifPic.GetWindowRect(&adbanerRect); m_btnSelectPath.GetWindowRect(&btnSelectPathRect); m_btnStart.GetWindowRect(&btnStartRect); //如何鼠标在广告位置或按钮上,改变鼠标指针 if(adbanerRect.PtInRect(point)||btnSelectPathRect.PtInRect(point)||btnStartRect.PtInRect(point)) SetCursor(AfxGetApp()->LoadStandardCursor(IDC_HAND)); CDialog::OnMouseMove(nFlags, point); }
光有上面一个函数还是不行的,还需要重载CWnd类的虚拟函数PreTranslateMessage()[cpp] view plain copy print?BOOL CbpmDlg::PreTranslateMessage(MSG *pMsg) { if(pMsg->message == WM_MOUSEMOVE) { OnMouseMove(pMsg->wParam,pMsg->pt); } return CDialog::PreTranslateMessage(pMsg); }
相关文章推荐
- VC让鼠标指到按钮上变成手型
- VC让鼠标指到按钮上变成手型
- 让鼠标指针移到按钮上方变成手型的代码例子
- MFC/VC中当鼠标停靠在按钮等控件上时出现文字提示功能
- 关于单击一个按钮时要执行一段代码:使鼠标变成漏斗;
- VC中实现按钮提示,使用CToolTipCtrl2007年01月23日 星期二 20:09如果你需要对对话框上的一个按钮进行鼠标停靠提示,那么这么做:
- VC中鼠标经过按钮弹出功能提示(TIPS)
- VC下利用Picture控件实现png图片按钮(鼠标初始、按下、松开、获得焦点四种状态)
- js鼠标变成手型
- MFC/VC中当鼠标停靠在按钮等控件上时出现文字提示功能
- VC下利用Picture控件实现png图片按钮(鼠标初始、按下、松开、获得焦点四种状态)
- VC中当鼠标停靠在按钮等控件上时出现文字提示功能
- 修复duilib-移动鼠标到Button不能变成手型
- VC下利用Picture控件实现png图片按钮(鼠标初始、按下、松开、获得焦点四种状态)
- 当鼠标按钮停在按钮上变手型
- html实现鼠标悬停变成手型实现方式
- 当鼠标放在按钮上时让指针变为手型
- MFC/vc中当鼠标经过按钮等控件时出现文字提示功能
- flex鼠标移到某组件鼠标的形状变成手型
- Flex组件上鼠标指针变成手型