没用过那个getrgnbox,不过我前几天用了GetRegionData和getpath,你可以看看<br>unit Unit1;<br><br>interface<br><br>uses<br> Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,<br> StdCtrls;<br><br>type<br> TForm1 = class(TForm)<br> Button1: TButton;<br> procedure Button1Click(Sender: TObject);<br> private<br> { Private declarations }<br> public<br> { Public declarations }<br> end;<br><br>var<br> Form1: TForm1;<br><br>implementation<br><br>{$R *.DFM}<br>procedure TForm1.Button1Click(Sender: TObject);<br>var<br> a_array:array[1..10] of tpoint;<br> h:hrgn;<br> rectdata
RgnData;<br> li_temp:integer;<br> pint
smallint;<br> i:integer;<br> r:trect;<br> ppo,<br> ppoo
point;<br> pb:integer;<br> size:integer;<br>begin<br> a_array[1].x:=12;<br> a_array[1].y:=12;<br> a_array[2].x:=100;<br> a_array[2].y:=12;<br> a_array[3].x:=100;<br> a_array[3].y:=200;<br> a_array[4].x:=50;<br> a_array[4].y:=50;<br> a_array[5].x:=312;<br> a_array[5].y:=100;<br>h:=CreatePolygonRgn(a_array,5,WINDING);<br> beginpath(canvas.handle);<br> canvas.Polygon(Slice(a_array, 5));<br> endpath(canvas.handle);<br><br>// getmem(ppoo,sizeof(tpoint));<br> size:=getpath(canvas.handle,ppoo^,pb,0);<br> getmem(ppoo,sizeof(tpoint)*size);<br> getpath(canvas.handle,ppoo^,pb,size);<br> ppo:=ppoo;<br> caption:='';<br> for i:=0 to 4 do<br> begin<br> caption:=caption+inttostr(ppoo^.x)+':'+inttostr(ppoo^.y)+':';<br> if i<4 then<br> inc(ppoo,1);<br> end;<br> ppoo:=ppo; <br> freemem(ppoo);<br><br> li_temp:=GetRegionData(h,0,nil);<br> rectdata:=AllocMem(li_temp);<br> GetRegionData(h,li_temp,rectdata);<br>// showmessage(floattostr(rectdata^.rdh.nRgnSize / rectdata^.rdh.nCount));<br>// caption:=floattostr(rectdata^.rdh.nRgnSize / rectdata^.rdh.nCount);<br> pint:=@rectdata^.buffer[0];<br> for i:=0 to rectdata^.rdh.nCount-1 do<br> begin<br> r.Left :=pint^;<br> inc(pint,sizeof(smallint));<br> r.top :=pint^;<br> inc(pint,sizeof(smallint));<br> r.right:=pint^;<br> inc(pint,sizeof(smallint));<br> r.bottom:=pint^;<br> inc(pint,sizeof(smallint));<br> canvas.brush.Color :=clgreen;<br> CANVAS.pen.Color :=clred;<br> canvas.Rectangle(r);<br> end;<br> freemem(rectdata); <br>deleteobject(h);<br>end;<br>end.<br>