function inornot(p:tpoint;rec:trect):boolean; begin result:=false; if (p.x>=rec1.aleft) and (p.x<=rec1.aright) and (p.y<=rec1.abottom) and (p.x>=rec1.atop) then result:=true; end;
function inornot(p:tpoint;rec:trect):boolean; begin result:=false; if (p.x>=rec1.aleft) and (p.x<=rec1.aright) and (p.y<=rec1.abottom) and (p.y>=rec1.atop) then //改了一下 result:=true; end;
procedure TForm1.Button1Click(Sender: TObject); var Rhnd:THandle; sRect:TRect; begin sRect := Rect(0,0,100,100); Rhnd:=CreateRectRgnIndirect(sRect); if PtInRegion(RHnd,x,y) then //点坐标(x,y) showmessage('Yes') else showmessage('No') end;
begin
result:=false;
if (p.x>=rec1.aleft) and
(p.x<=rec1.aright) and
(p.y<=rec1.abottom) and
(p.x>=rec1.atop) then
result:=true;
end;
begin
result:=false;
if (p.x>=rec1.aleft) and
(p.x<=rec1.aright) and
(p.y<=rec1.abottom) and
(p.y>=rec1.atop) then //改了一下
result:=true;
end;
var
Rhnd:THandle;
sRect:TRect;
begin
sRect := Rect(0,0,100,100);
Rhnd:=CreateRectRgnIndirect(sRect);
if PtInRegion(RHnd,x,y) then //点坐标(x,y)
showmessage('Yes')
else
showmessage('No')
end;
不过要用deleteobject(rhnd),
不然你win98的资源就完了。
PtInRect可能写错了!!!