我在WM_MOUSEMOVE事件中添加如下处理实现 当鼠标在对话框内移动时设置窗口不透明,一旦鼠标移出窗口窗口变为透明的 
void CXXXDlg::OnMouseMove(UINT nFlags, CPoint point)
{
CRect rect;
GetClientRect(rect);
//GetWindowRect(rect);
//ClientToScreen(rect);
//ClientToScreen(&point);
//GetCursorPos(&point);
if (rect.PtInRect(point))
{
SetLayeredWindowAttributes(0, 255, LWA_ALPHA);
                   SetCapture();
}
else
{

SetLayeredWindowAttributes( 0, 168, LWA_ALPHA);
ReleaseCapture();
} CDialog::OnMouseMove(nFlags, point);
}
 由于SetCapture();捕获鼠标后窗口内鼠标单击窗口内的按钮或控件没有了响应请高手给出一个解决的办法

解决方案 »

  1.   

    用定时器吧。在定时器中判断当前鼠标的位置是否在窗口中。或者加上mouse leave消息,而不要Set capture.
      

  2.   

    一种是用TrackMouseEvent;另一种是MouseHook
      

  3.   

    如果响应要求很快,用SetWindowsHookEx,否则用定时器吧。
      

  4.   

    还是用定时器的方法好,每隔一小段时间检查鼠标位置在不在自己窗体区域内。钩子有点占资源,TrackMouseEvent效果也不太理想(进入子窗口区域也算是“离开”窗口了)。
      

  5.   

    看了各位大虾的方案觉得定时器比较简单 但不知效率怎样。粗略的感觉好像没有影响
    SetTimer(1, 100, NULL);void CXXXDlg::OnTimer(UINT nIDEvent)
    {
    CPoint point;
    GetCursorPos(&point);
    CRect rect;
    GetClientRect(rect);
    //GetWindowRect(rect);
    ClientToScreen(rect);
    //ClientToScreen(&point);
    //GetCursorPos(&point);
    if (rect.PtInRect(point))
    {
    SetLayeredWindowAttributes(0, 255, LWA_ALPHA);
    //SetCapture();
    }
    else
    { SetLayeredWindowAttributes( 0, 168, LWA_ALPHA);
    //ReleaseCapture();
    } CBCGPDialog::OnTimer(nIDEvent);
    }