This example effect chart:
Code files:Unit Unit1;
Interface
Uses
Windows, Messages, sysutils, variants, Classes, Graphics, Controls, Forms,
Dialogs, Stdctrls, Grids;
Type
TForm1 = Class (Tform)
Stringgrid1:tstringgrid;
Procedure Formcreate (Sender:tobject);
Procedure Formpaint (Sender:tobject);
Procedure Stringgrid1selectcell (Sender:tobject; Acol, Arow:integer;
var canselect:boolean);
End
Var
Form1:tform1;
Implementation
{$R *.DFM}
Uses Gdipobj, GDIPAPI;
Procedure Tform1.formcreate (Sender:tobject);
Begin
Stringgrid1.align: = Alright;
Stringgrid1.fixedcols: = 0;
Stringgrid1.colcount: = 3;
Stringgrid1.colwidths[0]: = 25;
STRINGGRID1.COLWIDTHS[1]: = 25;
STRINGGRID1.COLWIDTHS[2]: = 80;
Stringgrid1.defaultrowheight: = 20;
stringgrid1.cells[0,0]: = ' X ';
stringgrid1.cells[1,0]: = ' Y ';
stringgrid1.cells[2,0]: = ' point type ';
End
Procedure Tform1.formpaint (Sender:tobject);
Var
G:tgpgraphics;
P:tgppen;
Path:tgpgraphicspath;
Points:array of Tgppoint;
Types:pbyte;
typestr:string;
I:integer;
Begin
G: = Tgpgraphics.create (Canvas.handle);
P: = tgppen.create (aclred);
Path: = Tgpgraphicspath.create;
Path. Startfigure;
Path. AddRectangle (Makerect (30,20,90,40));
Path. AddEllipse (Makerect (30,80,90,180));
Path. Closefigure;
G.drawpath (P, path);
SetLength (points, path.) Getpointcount);
Getmem (types, path.) Getpointcount);
Path. Getpathpoints (Pgppoint (points), Length (points));
Path. Getpathtypes (types, Length (points));
Stringgrid1.rowcount: = Length (points) + 1;
For I: = 0 to Length (points)-1 do
Begin
Case types^ of
$00:TYPESTR: = ' path start point ';
$01:typestr: = ' straight point ';
$03:typestr: = ' Bezier line point ';
$07:typestr: = ' hiding point ';
$10:typestr: = ' dotted point ';
$20:TYPESTR: = ' path mark ';
$80:TYPESTR: = ' Sub path end point ';
End
Stringgrid1.cells[0, i+1]: = IntToStr (points[i). X);
Stringgrid1.cells[1, i+1]: = IntToStr (points[i). Y);
Stringgrid1.cells[2, i+1]: = TYPESTR;
INC (types);
End
DEC (types, Length (points));
Freemem (types);
Types: = nil;
Path. Free;
P.free;
G.free;
End
Procedure Tform1.stringgrid1selectcell (Sender:tobject; Acol, Arow:integer;
var canselect:boolean);
Var
X,y:integer;
Begin
x: = Strtointdef (Stringgrid1.cells[0,arow], 0);
Y: = Strtointdef (Stringgrid1.cells[1,arow], 0);
Repaint;
Canvas.Brush.Color: = Clblue;
Canvas.fillrect (Bounds (x-3,y-3,6,6));
Text: = Format ('%d,%d ', [x,y]);
End
End.