home *** CD-ROM | disk | FTP | other *** search
/ Delphi Magazine Collection 2001 / Delphi Magazine Collection 20001 (2001).iso / DISKS / Issue65 / system / TestGdiPlus.pas < prev   
Encoding:
Pascal/Delphi Source File  |  2000-11-29  |  1.8 KB  |  77 lines

  1. unit TestGdiPlus;
  2.  
  3. interface
  4.  
  5. uses
  6.   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  7.   StdCtrls;
  8.  
  9. type
  10.   TForm1 = class(TForm)
  11.     Label1: TLabel;
  12.     procedure FormPaint(Sender: TObject);
  13.     procedure FormResize(Sender: TObject);
  14.   private
  15.     { Private declarations }
  16.   public
  17.     { Public declarations }
  18.   end;
  19.  
  20. var
  21.   Form1: TForm1;
  22.  
  23. implementation
  24.  
  25. {$R *.DFM}
  26.  
  27. uses GDIPlus;
  28.  
  29. procedure TForm1.FormPaint(Sender: TObject);
  30. var
  31.     Graphics, Brush, PGB, Path: Integer;
  32.     Points: array [0..3] of GPPointF;
  33. begin
  34.     // Use GDI+ for all our form painting....
  35.     if GdipCreateFromHDC (Canvas.Handle, Graphics) = 0 then try
  36.  
  37.         GdipCreateHatchBrush (bsBackwardDiagonal, $80000080, $ffff3312, Brush);
  38.  
  39.         if GdipCreatePath (Winding, Path) = 0 then try
  40.  
  41.             GdipAddPathLine (Path, 10, 10, 200, 100);
  42.             GdipAddPathLine (Path, 200, 100, 200, 200);
  43.             GdipAddPathLine (Path, 200, 200, 100, 200);
  44.             GdipAddPathLine (Path, 100, 200, 100, 100);
  45.  
  46.             points[0].X := 300;  points[0].Y := 100;
  47.             points[1].X := 350;  points[1].Y := 200;
  48.             points[2].X := 300;  points[2].Y := 300;
  49.             points[3].X := 50;   points[3].Y := 500;
  50.             GdipAddPathBeziers (Path, Points[0], 4);
  51.  
  52.             if GdipCreatePathGradientFromPath (Path, PGB) = 0 then try
  53.  
  54.                 GdipSetPathGradientCenterColor (PGB, $FF0000FF);
  55.                 GdipFillPath (Graphics, PGB, Path);
  56.  
  57.             finally
  58.                 GdipDeleteBrush (PGB);
  59.             end;
  60.             
  61.         finally
  62.             GdipDeletePath (Path);
  63.             GdipDeleteBrush (Brush);
  64.         end;
  65.  
  66.     finally
  67.         GdipDeleteGraphics (Graphics);
  68.     end;
  69. end;
  70.  
  71. procedure TForm1.FormResize(Sender: TObject);
  72. begin
  73.     Invalidate;
  74. end;
  75.  
  76. end.
  77.