home *** CD-ROM | disk | FTP | other *** search
- unit TestGdiPlus;
-
- interface
-
- uses
- Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
- StdCtrls;
-
- type
- TForm1 = class(TForm)
- Label1: TLabel;
- procedure FormPaint(Sender: TObject);
- procedure FormResize(Sender: TObject);
- private
- { Private declarations }
- public
- { Public declarations }
- end;
-
- var
- Form1: TForm1;
-
- implementation
-
- {$R *.DFM}
-
- uses GDIPlus;
-
- procedure TForm1.FormPaint(Sender: TObject);
- var
- Graphics, Brush, PGB, Path: Integer;
- Points: array [0..3] of GPPointF;
- begin
- // Use GDI+ for all our form painting....
- if GdipCreateFromHDC (Canvas.Handle, Graphics) = 0 then try
-
- GdipCreateHatchBrush (bsBackwardDiagonal, $80000080, $ffff3312, Brush);
-
- if GdipCreatePath (Winding, Path) = 0 then try
-
- GdipAddPathLine (Path, 10, 10, 200, 100);
- GdipAddPathLine (Path, 200, 100, 200, 200);
- GdipAddPathLine (Path, 200, 200, 100, 200);
- GdipAddPathLine (Path, 100, 200, 100, 100);
-
- points[0].X := 300; points[0].Y := 100;
- points[1].X := 350; points[1].Y := 200;
- points[2].X := 300; points[2].Y := 300;
- points[3].X := 50; points[3].Y := 500;
- GdipAddPathBeziers (Path, Points[0], 4);
-
- if GdipCreatePathGradientFromPath (Path, PGB) = 0 then try
-
- GdipSetPathGradientCenterColor (PGB, $FF0000FF);
- GdipFillPath (Graphics, PGB, Path);
-
- finally
- GdipDeleteBrush (PGB);
- end;
-
- finally
- GdipDeletePath (Path);
- GdipDeleteBrush (Brush);
- end;
-
- finally
- GdipDeleteGraphics (Graphics);
- end;
- end;
-
- procedure TForm1.FormResize(Sender: TObject);
- begin
- Invalidate;
- end;
-
- end.
-