有好几种方法:1。比较笨的是判断鼠标的位置是否在按钮上面
             2。重载按钮的OnMouseMove,然后用TraceMouseEvent(好象是这样写记不太清 了)去检查,
           3,想不起来了,还有其他的方法,:)
             

解决方案 »

  1.   

    一个被Disable的窗口是不接受鼠标消息的,这样OnMouseMove就没用了。大概只能在Parent窗口中检查鼠标的位置,再Enable它了。
    比如,得到父窗口的hwnd,用EnumChildWindows枚举出所有Child的hwnd,用GetWindowRect得到Child的Rect,再判断鼠标的位置在那个Child上。
      

  2.   


        难道大家不知道ChildWindowFromPoint这个函数吗?使用它你可以得到鼠标位置下的窗口的句柄。ID当然也能得到。然后比较一下窗口类,看是不是BUTTON即可。就像spy++做的那样。
      

  3.   

    用 CWnd *pWnd = WindowFormPoint( point); //point 是鼠标的(屏幕范围)
    pWnd->EnableWndow();
      

  4.   

    用一个全局钩子Hook鼠标就可改变别的程序地按钮了。
      

  5.   

    如果在自己的程序里面可以处理 WM_SETCURSOR 事件 OnSetCursor,想对别的程序的按钮,就???不知道。
      

  6.   

    1、用HWND SetCapture(  HWND hWnd   
    // handle of window to receive mouse capture
    )扑获鼠标;
    2、用HWND WindowFromPoint(
      POINT Point   // structure with point
    )获得窗口句柄;
    3、用LONG GetWindowLong(
      HWND hWnd,  // handle of window
      int nIndex  // offset of value to retrieve
    )得到ID,其中nIndex参数为GWL_ID;
    4、用BOOL EnableWindow(
      HWND hWnd,     // handle to window
      BOOL bEnable   // flag for enabling or disabling input
    ) Enable or Disenable;