为什么不能释放鼠标?释放了鼠标之后光标不能移出区域。
void CEEGDemoDlg::OnLButtonDown(UINT nFlags, CPoint point) 
{
// TODO: Add your message handler code here and/or call default
SetCapture();
m_bMove=true; CDialog::OnLButtonDown(nFlags, point);
}void CEEGDemoDlg::OnMouseMove(UINT nFlags, CPoint point) 
{
// TODO: Add your message handler code here and/or call default

if (m_bMove)
{
CRect r;
m_CtrMap.GetWindowRect(&r); //m_CtrMap是一个edit控件
ClipCursor(&r);
}
CDialog::OnMouseMove(nFlags, point);
}void CEEGDemoDlg::OnLButtonUp(UINT nFlags, CPoint point) 
{
// TODO: Add your message handler code here and/or call default
ReleaseCapture();
m_bMove=false; CDialog::OnLButtonUp(nFlags, point);
}

解决方案 »

  1.   

    OnLButtonUp里加一句
    ClipCursor(NULL);
      

  2.   

    再OnLButtonUp(UINT nFlags, CPoint point)中加一句:
      ClipCursor(NULL);
      

  3.   

    The cursor is a shared resource. If an application confines the cursor, it must release the cursor by using ClipCursor before relinquishing control to another application. lpRect 
    [in] Long pointer to the RECT structure that contains the screen coordinates of the upper-left and lower-right corners of the confining rectangle. If this parameter is NULL, the cursor is free to move anywhere on the screen