在做一个对话框内采集CCD图像的程序
对话框类CImageCCD
添加了一个静态控件 ID:IDC_STATICVIDEO
定义一个CStatic变量
 DDX_Control(pDX, IDC_STATICVIDEO, m_cStaticVideoWindow);
CRect m_ControlREC;//关联控件位置大小的矩阵
在OnInitDialog()中初始化控件大小
// Assign this window to the Grabber object for live video display.
m_cGrabber.setHWND(m_cStaticVideoWindow.m_hWnd);
        CWnd *pWnd = GetDlgItem(IDC_STATICVIDEO);
pWnd->GetClientRect(&m_ControlREC);
m_ControlREC.bottom = m_ControlREC.top + 480;
m_ControlREC.right = m_ControlREC.left + 360;
pWnd->ClientToScreen(&m_ControlREC);
CRect rect;
GetClientRect(rect);
ClientToScreen(&rect);
m_ControlREC.OffsetRect( -rect.left, -rect.top );
pWnd->MoveWindow(m_ControlREC.left,m_ControlREC.top,m_ControlREC.Width(),m_ControlREC.Height(),TRUE);添加鼠标响应afx_msg void OnMouseMove(UINT nFlags, CPoint point);
void CImageCCD::OnMouseMove(UINT nFlags, CPoint point)
{
if (m_ControlREC.PtInRect(point))
{
               ::SetCursor(::LoadCursor(NULL,IDC_CROSS));
point.x -= m_ControlREC.left;
point.y -= m_ControlREC.top;
                   ……
                   ……
// TODO: 在此添加消息处理程序代码和/或调用默认值
}
CDialog::OnMouseMove(nFlags, point);
}问题来了:
当CCD图像没有开启时候,对话框内(包含静态控件区域)的鼠标响应一切正常,但是一旦开启视频后,OnMouseMove在图像区域无法响应,无法获取坐标信息,非常困惑,请大家帮帮忙!

解决方案 »

  1.   

    个人认为有窗口覆盖了你的控件的位置,
    可以试试在 PreTranslateMessage 中处理BOOL CXXXDlg::PreTranslateMessage(MSG* pMsg) 
    {
      // TODO: Add your specialized code here and/or call the base class
      if(pMsg->message == WM_MOUSEMOVE)
      {
        TRACE(_T("WM_MOUSEMOVE fwKeys=%ld xPos=%d yPos=%d\n"),
          pMsg->wParam, LOWORD(pMsg->lParam), HIWORD(pMsg->lParam));
      }
      return CDialog::PreTranslateMessage(pMsg);
    }
      

  2.   

    已经解决!
    //获取鼠标点
                POINT point ; 
                ::GetCursorPos( &point ); 
                ScreenToClient( &point ) ;