mfc判断当前鼠标位置是否属于bmp矩形内
在文档视图中,怎样判断鼠标移动时是否属于bmp矩形区域内(当然视图中是有多个bmp图形的),是,则高亮显示? 判断鼠标位置是否属于矩形区
[解决办法]
有现成的函数,忘记是啥了,不用函数也很简单啊。
在OnMouseMove中判断鼠标的x坐标在图片的x范围内,y坐标在图片的y范围内不就完了
[解决办法]
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