如何判断一个点是否在一个RECT内?(2分)

C

cjg325

Unregistered / Unconfirmed
GUEST, unregistred user!
如何判断一个点是否在一个RECT内?
 
function ptinRect(p: TPoint;r:TRect): Boolean;
好象是这个函数
 
Result := (Point.X >= Rect.Left) and
(Point.X <= Rect.Right) and
(Point.Y >= Rect.Top) and
(Point.Y <= Rect.Bottom);
 
dX1,dY1,dX2,dY2 是矩形
function IsPtInRect(dX, dY: Double; dX1,dY1,dX2,dY2 : double):Boolean;
const
dBuf : double = 10e-10;
begin
Result := (dX > MinValue([dX1,dX2])- dBuf) and (dX < MaxValue([dX1,dX2]) + dBuf) and
(dY > MinValue([dY1,dY2]) - dBuf) and (dY < MaxValue([dY1,dY2]) + dBuf);
end;
 
听一下~
 
同意zhukewen的说法,有函数不用,岂不很傻
 
有办法得一个圆形区域吗?如果可以,又如何判断某点是否在区域内?
 
pTinRegion
 
用PtInRect API函数
 
接受答案了.
 
顶部