获取picture control控件所占区域的坐标 鼠标 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 GetWindowRect,GetCursorPos,PtInRect获取判断是否在picture control里,是的话有需要可以再把这个点用ScreenToClient转换一下 这是我的程序:void Cw_dispctrlDlg::OnMouseMove(UINT nFlags, CPoint point){ // TODO: 在此添加消息处理程序代码和/或调用默认值 CRect rect; //CPoint pt0; CString str_coordinate; GetDlgItem(IDC_STATIC1)->GetWindowRect(&rect); ScreenToClient(&rect); //ScreenToClient(&pt0); if(rect.PtInRect(point)) { str_coordinate.Format("%d,%d",point.x,point.y); edit_status9.SetWindowText(str_coordinate); } else { edit_status9.SetWindowText(_T("1")); } CDialogEx::OnMouseMove(nFlags, point);}控件IDC_STATIC1旁边还有很多其他控件是连着放的,现在出现的情况就是只有鼠标移到对话框本身的空白区域的时候才显示1,而如果从IDC_STATIC1移到其他控件上时,坐标值就固定不变了,不知道是为什么呢? 在PreTranslateMessage中拦截WM_MOUSEMOVE消息,然后再处理,记得Point用GetCursorPos获取 void Cw_dispctrlDlg::OnMouseMove(UINT nFlags, CPoint point){ // TODO: 在此添加消息处理程序代码和/或调用默认值 CRect rect; //CPoint pt0; CString str_coordinate; GetDlgItem(IDC_STATIC1)->GetWindowRect(&rect); ScreenToClient(&rect); //ScreenToClient(&pt0); if(rect.PtInRect(point)) { str_coordinate.Format("%d,%d",point.x,point.y); edit_status9.SetWindowText(str_coordinate); } else { edit_status9.SetWindowText(_T("1")); } CDialogEx::OnMouseMove(nFlags, point);}BOOL Cw_dispctrlDlg::PreTranslateMessage(MSG* pMsg){ // TODO: 在此添加专用代码和/或调用基类 CPoint pt; if(pMsg->wParam==WM_MOUSEMOVE) { ::GetCursorPos( &pt ); } return CDialogEx::PreTranslateMessage(pMsg);}是这样吗?好像还是没有什么效果,我是新手,能不能指导再具体一些。万分感谢! MFC对话框中如何显示JPG图片 继续问CString.Format问题 Frame和viwe问题,为什么? 怎么使位图背景在应用程序中透明啊? 这个消息函数谁调用它?咋消息映射表里没有消息映射? 如何用VC实现串口通信 关于CreateProcess 如何使某个菜单项不能使用? 特殊的运行错误!运行后提示“ assertion failed,"afxwin1.inl" ln22 " 菜鸟之声! 几个问题? ^o^ 飞鸟快请进 BHO如何添加事件处理? 自绘按钮。出现重影
void Cw_dispctrlDlg::OnMouseMove(UINT nFlags, CPoint point)
{
// TODO: 在此添加消息处理程序代码和/或调用默认值
CRect rect;
//CPoint pt0;
CString str_coordinate;
GetDlgItem(IDC_STATIC1)->GetWindowRect(&rect);
ScreenToClient(&rect);
//ScreenToClient(&pt0);
if(rect.PtInRect(point))
{
str_coordinate.Format("%d,%d",point.x,point.y);
edit_status9.SetWindowText(str_coordinate);
}
else
{
edit_status9.SetWindowText(_T("1"));
} CDialogEx::OnMouseMove(nFlags, point);
}
控件IDC_STATIC1旁边还有很多其他控件是连着放的,现在出现的情况就是只有鼠标移到对话框本身的空白区域的时候才显示1,而如果从IDC_STATIC1移到其他控件上时,坐标值就固定不变了,不知道是为什么呢?
{
// TODO: 在此添加消息处理程序代码和/或调用默认值
CRect rect;
//CPoint pt0;
CString str_coordinate;
GetDlgItem(IDC_STATIC1)->GetWindowRect(&rect);
ScreenToClient(&rect);
//ScreenToClient(&pt0);
if(rect.PtInRect(point))
{
str_coordinate.Format("%d,%d",point.x,point.y);
edit_status9.SetWindowText(str_coordinate);
}
else
{
edit_status9.SetWindowText(_T("1"));
} CDialogEx::OnMouseMove(nFlags, point);
}
BOOL Cw_dispctrlDlg::PreTranslateMessage(MSG* pMsg)
{
// TODO: 在此添加专用代码和/或调用基类
CPoint pt;
if(pMsg->wParam==WM_MOUSEMOVE)
{
::GetCursorPos( &pt );
}
return CDialogEx::PreTranslateMessage(pMsg);
}
是这样吗?好像还是没有什么效果,我是新手,能不能指导再具体一些。万分感谢!