1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91
| unit Unit2;
interface
uses Windows,Forms,Graphics,Types;
procedure Fenetre_Polygone(AForm:TForm;AngleDebut:integer;NbreCotes:integer);
procedure Fenetre_Etoile(AForm:TForm;AngleDebut:integer;NbreBranches,TailleBranche:integer);
procedure Fenetre_Ellipse(AForm:TForm);
procedure Fenetre_CoinsArrondis(AForm:TForm;RayonHorizontal,RayonVertical:integer);
implementation
procedure Fenetre_Polygone(AForm:TForm;AngleDebut:integer;NbreCotes:integer);
var
hRegion: HRGN;
Poly: array of TPoint;
Centre:TPoint;
Angle:Real;
i:Integer;
x,y: Integer;
RayonX,RayonY:Integer;
begin
SetLength(Poly,NbreCotes);
RayonY:=AForm.Height div 2;
rayonX:=AForm.Width div 2;
Centre:=Point(AForm.Width div 2,AForm.Height div 2);
//Calcul du polygone
i:=0;
Angle:=0;
for i:=0 to NbreCotes-1 do
begin
Angle:=i*2*PI/NbreCotes+AngleDebut*PI/180;
x:=Centre.X+round(RayonX*cos(Angle));
y:=Centre.Y+round(RayonY*sin(Angle));
Poly[i]:=Point(x,y);
end;
//Creation de la forme
hRegion := CreatePolygonRgn(Poly[0], NbreCotes, WINDING);
SetWindowRgn(AForm.Handle, hRegion, True);
end;
procedure Fenetre_Etoile(AForm:TForm;AngleDebut:integer;NbreBranches,TailleBranche:integer);
var
hRegion: HRGN;
Poly: array of TPoint;
Centre:TPoint;
Angle:Real;
i:Integer;
x,y: Integer;
RayonX,RayonY:Integer;
begin
SetLength(Poly,NbreBranches*2);
RayonY:=AForm.Height div 2;
rayonX:=AForm.Width div 2;
Centre:=Point(AForm.Width div 2,AForm.Height div 2);
//Calcul du polygone
i:=0;
Angle:=0;
for i:=0 to (NbreBranches*2)-1 do
begin
Angle:=i*2*PI/(NbreBranches*2);//+AngleDebut*PI/180;
if Odd(i) then
begin
x:=Centre.X+round(RayonX*(100-TailleBranche)*cos(Angle)/100);
y:=Centre.Y+round(RayonY*(100-TailleBranche)*sin(Angle)/100);
end else
begin
x:=Centre.X+round(RayonX*cos(Angle));
y:=Centre.Y+round(RayonY*sin(Angle));
end;
Poly[i]:=Point(x,y);
end;
//Creation de la forme
hRegion := CreatePolygonRgn(Poly[0], NbreBranches*2, WINDING);
SetWindowRgn(AForm.Handle, hRegion, True);
end;
procedure Fenetre_Ellipse(AForm:TForm);
var hRegion: HRGN;
begin
hRegion := CreateEllipticRgn(0,0,AForm.Width,AForm.Height);
SetWindowRgn(AForm.Handle, hRegion, True);
end;
procedure Fenetre_CoinsArrondis(AForm:TForm;RayonHorizontal,RayonVertical:integer);
var hRegion: HRGN;
begin
hRegion := CreateRoundrectRgn(0,0,AForm.Width,AForm.Height,RayonHorizontal,RayonVertical);
SetWindowRgn(AForm.Handle, hRegion, True);
end;
end. |
Partager