From: alanglloyd@aol.com (AlanGLLoyd) Subject: Christmas Star Date: 16 Dec 1999 00:00:00 GMT Message-ID: <19991216073031.28201.00000323@ngol02.aol.com> Organization: AOL, http://www.aol.co.uk Newsgroups: comp.lang.pascal.delphi.misc X-Admin: news@aol.com Drop a label (Label1) on a new form, set the form's width to about half the screen width and put the following code into the form's code. Double-click on the text to exit. Drag the small blue spot at the top to move; If you're really stuck e-mail me and I'll send you the .exe with its code. . . . and a Happy Christmas to All Alan Lloyd alanglloyd@aol.com type TPent = array[0..4] of TPoint; TForm1 = class(TForm) Label1: TLabel; procedure FormCreate(Sender: TObject); procedure Label1DblClick(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form1: TForm1; implementation {$R *.DFM} function MakePent(X, Y, L : integer) : TPent; var DX1, DY1, DX2, DY2 : integer; const Sin54 = 0.809; Cos54 = 0.588; Tan72 = 3.078; begin DX1 := trunc(L * Sin54); DY1 := trunc(L * Cos54); DX2 := L div 2; DY2 := trunc(L * Tan72 / 2); Result[0] := point(X, Y); Result[1] := point(X - DX1, Y + DY1); Result[2] := point(X - DX2, Y + DY2); Result[3] := point(X + DX2, Y + DY2); Result[4] := point(X + DX1, Y + DY1); end; procedure DrawPentacle(Canvas : TCanvas; Pent : TPent); begin with Canvas do begin MoveTo(Pent[0].X, Pent[0].Y); LineTo(Pent[2].X, Pent[2].Y); LineTo(Pent[4].X, Pent[4].Y); LineTo(Pent[1].X, Pent[1].Y); LineTo(Pent[3].X, Pent[3].Y); LineTo(Pent[0].X, Pent[0].Y); end; {with Canvas} end; procedure TForm1.FormCreate(Sender: TObject); var L : integer; Pent : TPent; StarRgn : hRgn; const Sin54 = 0.809; Tan72 = 3.078; begin Label1.OnDblClick := Label1DblClick; L := trunc((Self.ClientHeight - 10) * 2 / Tan72); Width := trunc(L * Sin54 * 2) + 10; Color := clRed; with Font do begin Color := clGreen; Size := L div 11; Name := 'Arial'; Style := [fsBold]; end; {draw a pentacle and make it the window's region} Pent := MakePent(Self.Width div 2, 0, L); BeginPath(Self.Canvas.Handle); DrawPentacle(Self.Canvas, Pent); EndPath(Self.Canvas.Handle); SetPolyFillMode(Self.Canvas.Handle, WINDING); StarRgn := PathToRegion(Self.Canvas.Handle); SetWindowRgn(Self.Handle, StarRgn, true); with Label1 do begin Caption := 'Happy Christmas'; Alignment := taCenter; Width := Self.Canvas.TextWidth(Caption); Height := Self.Canvas.TextHeight('Hy'); Left := (Self.Width - Width) div 2; Top := Pent[1].Y - (Self.Height - Self.ClientHeight) + (Height div 2); end; end; procedure TForm1.Label1DblClick(Sender: TObject); begin Self.Close; end;