CombineRgn,俺用了什么没有变成新的区域出来呢?代码如下:(20分)

  • 主题发起人 主题发起人 LinSongQ
  • 开始时间 开始时间
L

LinSongQ

Unregistered / Unconfirmed
GUEST, unregistred user!
请问错在哪呢?谢谢
procedure TForm1.Button1Click(Sender: TObject);
Var acme:array [0..3] of Tpoint;
Hand1,Hand2,Hand3:Longint;
begin
acme[0]:=Point(50,50);
acme[1]:=Point(150,50);
acme[2]:=Point(150,150);
acme[3]:=Point(50,150);
image1.Canvas.Rectangle(acme[0].x,acme[0].y,acme[2].x,acme[2].y);
Hand1:=CreatePolygonRgn(acme[0],4,1);
Hand2:=CreatePolygonRgn(acme[0],3,1);
Hand3:=0;
CombineRgn(Hand3,Hand1,Hand2,RGN_OR);//这里合并后,新的区域在hand3里.
SelectClipRgn(Image1.Canvas.Handle ,Hand3);//在这里限制后没用????
with image1.Canvas do begin
MoveTo(0,image1.height);
Lineto(200,0);
end;
SelectClipRgn(Image1.Canvas.Handle ,0);
deleteobject(Hand1);
deleteobject(Hand2);
end;
 
好好看看帮助!

The CombineRgn function combines two regions and stores the result in a third region.
The two regions are combined according to the specified mode.

int CombineRgn(

HRGN hrgnDest, // handle to destination region
HRGN hrgnSrc1, // handle to source region
HRGN hrgnSrc2, // handle to source region
int fnCombineMode // region combining mode
);


Parameters

hrgnDest

Identifies a new region with dimensions defined by combining two other regions.
(This region must exist before CombineRgn is called.) //注意到了么???

hrgnSrc1

Identifies the first of two regions to be combined.

hrgnSrc2

Identifies the second of two regions to be combined.

你合并后的区域在你进行合并之前必须存在,不能为空!
所以 :

Hand1:=CreatePolygonRgn(acme[0],4,1);
Hand2:=CreatePolygonRgn(acme[0],3,1);
Hand3:=Hand1;
 
呜......俺看到了,但没注意到那是目的区域要存在,还以为是源区域需存在的....


下次小心了.谢谢
 
后退
顶部