delphi 判断鼠标的位置是否在某一控键上

解决方案 »

  1.   

    参考方法:
    function ControlAtPos(const Pos: TPoint; AllowDisabled: Boolean, AllowWinControls:Boolean=False): TControl;你也可以通过控件的位置和大小,用ClientToScreen函数扩展到屏幕坐标,然后用GetCursorPos得到当前鼠标位置进行判断。
      

  2.   

    var
     P: tpoint;
     h: thandle;getCursorpos(p);
    h:= windowFromPoint(p);if h= wincontrol.handle then
      showmessage('在某一控键上');
      

  3.   

    onmouseenter这个方法好些,不必要太复杂了。
      

  4.   

    三楼的方法通用性更强些,可用于任何控件的判断,而用onmouseenter,则必需在每个需要的控件上设置onmouse.....事件.
      

  5.   

    var 
    P: tpoint; 
    h: thandle; getCursorpos(p); 
    h:= windowFromPoint(p); if h= wincontrol.handle then 
      showmessage('在某一控键上');好方法