This example effect chart:
Code files:Unit Unit1;
Interface
Uses
Windows, Messages, sysutils, variants, Classes, Graphics, Controls, Forms,
Dialogs, Stdctrls;
Type
TForm1 = Class (Tform)
Button1:tbutton;
Button2:tbutton;
Procedure Formmouseup (Sender:tobject; Button:tmousebutton;
Shift:tshiftstate; X, Y:integer);
Procedure Formpaint (Sender:tobject);
Procedure Button1Click (Sender:tobject);
Procedure Button2click (Sender:tobject);
End
Var
Form1:tform1;
Implementation
{$R *.DFM}
Uses Gdipobj, GDIPAPI;
Var
Ptarr:array of Tgppoint;
I:integer = 0;
Procedure Tform1.formmouseup (Sender:tobject; Button:tmousebutton;
Shift:tshiftstate; X, Y:integer);
Begin
Canvas.ellipse (X-2, Y-2, x+2, y+2);
INC (i);
SetLength (Ptarr, i);
PTARR[I-1]. x: = x;
PTARR[I-1]. Y: = y;
Text: = IntToStr (i);
End
Procedure Tform1.formpaint (Sender:tobject);
Var
G:tgpgraphics;
P:tgppen;
Begin
G: = Tgpgraphics.create (Canvas.handle);
P: = Tgppen.create (aclred, 2);
G.clear (Aclwhite);
{If it is a dynamic array, it needs to be @PtArr, but the dynamic array itself is a pointer}
G.drawlines (P, Pgppoint (Ptarr), Length (Ptarr));
G.free;
P.free;
End
Procedure Tform1.button1click (Sender:tobject);
Begin
I: = 0;
SetLength (Ptarr, i);
Repaint;
Text: = IntToStr (i);
End
Procedure Tform1.button2click (Sender:tobject);
Begin
Repaint;
End
End.