procedure Tfrm_chart.setmywin;
var
temprgn:hrgn;
bmp:TBitmap ;
x,y,x1,x2:integer;
mycolor:tcolor;
begin
bmp:=TBitmap.Create;
bmp.Width:=Chart1.Width;///你只需改这里
bmp.Height:=Chart1.Height;///你只需改这里
Chart1.PaintTo(bmp.Canvas,1,1);///你只需改这里例如 bmp.loadfromfile('f:/gg.bmp');
myrgn:=CreateRectRgn(0,0,0,0);
mycolor:=bmp.Canvas.Pixels[1,1];
for y:=1 to bmp.Heightdo
begin
x1:=-1;
x2:=-1;
for x:=1 to bmp.Widthdo
begin
if bmp.Canvas.Pixels[x,y]<>mycolor then
begin
x2:=x;
if x1<0 then
x1:=x;
end
else
begin
if (x1>0) and (x1<=x2) then
begin
temprgn:=CreateRectRgn(x1-1,y-1,x2,y);
CombineRgn(
myRgn , // handle to destination region
myRgn , // handle to source region
temprgn , // handle to source region
RGN_OR // region combining mode
);
DeleteObject(temprgn);
x1:=-1;
x2:=-1;
end;
end;
end;
end;
SetWindowRgn(
handle ,
myRgn,
true
);
bmp.Free;
end;