下面是我以前实现的函数,拿出来抛砖引玉:
{判断屏幕上的点是否在某控件上方}
function PointInControl(point:Tpoint;Control:TControl):Boolean;
begin
result := false;
if ((point.x>Control.Left) and (point.x<Control.Left+Control.Width) and
(point.y>Control.Top) and (point.y<Control.top+Control.height)) then
result := true;
end;
{判断屏幕上的点是否在某矩形区域内}
function PointInRect(point:Tpoint;Rect:TRect):Boolean;
begin
result := false;
if (point.x>=Rect.Left) and (point.x<=Rect.Right) and
(point.y>=Rect.Top) and (point.y<=Rect.Bottom) then
result := true
else
if (Rect.Left=Rect.Right) and (Rect.Left=point.x) then
result := true
else
if (Rect.Top=Rect.Bottom) and (Rect.Top=point.y) then
result := true;
查查MSDN,看来是以下两个函数的调有就可搞定了!
HRGN CreatePolygonRgn(
CONST POINT *lppt, // array of points
int cPoints, // number of points in array
int fnPolyFillMode // polygon-filling mode
);
BOOL PtInRegion(
HRGN hrgn, // handle to region
int X, // x-coordinate of point
int Y // y-coordinate of point
);
以前没用过这类函数,看来这两个函数刚好是我想要的,
多谢 datou, menxin 提点,送分了!