好象记得有一个函数可以知道一个点是否在一个矩形里面。
忘记了,是否有这样一个函数?
或者鼠标在某个矩形里面。

解决方案 »

  1.   

    CRect::PtInRect 
    BOOL PtInRect( POINT point ) const;Return ValueNonzero if the point lies within CRect; otherwise 0.ParameterspointContains a POINT structure or CPoint object.ResDetermines whether the specified point lies within CRect. A point is within CRect if it lies on the left or top side or is within all four sides. A point on the right or bottom side is outside CRect.Note   The rectangle must be normalized or this function may fail. You can call NormalizeRect to normalize the rectangle before calling this function.CRect Overview |  Class Members |  Hierarchy ChartSee Also   CRect::NormalizeRect,::PtInRect
      

  2.   

    或者API PtInRect
    PtInRect
    The PtInRect function determines whether the specified point lies within the specified rectangle. A point is within a rectangle if it lies on the left or top side or is within all four sides. A point on the right or bottom side is considered outside the rectangle. BOOL PtInRect(
      CONST RECT *lprc,  // pointer to structure with rectangle
      POINT pt           // structure with point
    );
     
    Parameters
    lprc 
    Pointer to a RECT structure that contains the specified rectangle. 
    pt 
    Specifies a POINT structure that contains the specified point. 
    Return Values
    If the specified point lies within the rectangle, the return value is nonzero.If the specified point does not lie within the rectangle, the return value is zero. Windows NT: To get extended error information, callGetLastError. QuickInfo
      Windows NT: Requires version 3.1 or later.
      Windows: Requires Windows 95 or later.
      Windows CE: Requires version 1.0 or later.
      Header: Declared in winuser.h.
      Import Library: Use user32.lib.See Also
    Rectangles Overview, Rectangle Functions, EqualRect, IsRectEmpty, POINT, RECT