有用定时器来解决这个问题的。
象CToolBar的按钮效果就是用定时器来做的。
当鼠标移到窗口中时,产生定时器。
定时器发现鼠标不再在窗口内时,就有所动作而后销毁自身。
你可以获得当前的鼠标位置,判断是否在窗口范围内,而不用担心是否在子控制中,或是在其它窗口中。

解决方案 »

  1.   

    看来真要用Timer刚才我做了下面代码,在经过标题条等非对话矿客户区时候不产生鼠标离开消息:(LRESULT CSpeakDlg::OnMouseLeave(WPARAM wParam, LPARAM lParam)
    { POINT pt;
    RECT rcWindow;
    GetWindowRect( &rcWindow );
    GetCursorPos( &pt );
    if(pt.x > rcWindow.right || pt.x < rcWindow.left
    || pt.y < rcWindow.top || pt.y > rcWindow.bottom)
    MessageBox("mouse leaves",NULL,MB_OK);
             return 0;
    }
      

  2.   

    我的控件靠近对话框边缘,
    目前,鼠标从边缘的对话框划过,离开对话框时候,不产生WM_MOUSELEAVE消息:(
      

  3.   

    the following change may be help you;POINT pt;
    RECT rcWindow;
    GetClientRect( &rcWindow );
    ClientToScreen(&rcWindow);
    GetCursorPos( &pt );
    if(pt.x >= rcWindow.right || pt.x <= rcWindow.left
    || pt.y <= rcWindow.top || pt.y >= rcWindow.bottom)
    MessageBox("mouse leaves",NULL,MB_OK);
      

  4.   

    当鼠标移进窗口时,SetCapture(),移出时ReleaseCapture(),再向系统返回一个鼠标信息。
    不知可以吗。没有试过。