This example effect chart:
Code files:Unit Unit1;
Interface
Uses
Windows, Messages, sysutils, variants, Classes, Graphics, Controls, Forms,
Dialogs;
Type
TForm1 = Class (Tform)
Procedure Formpaint (Sender:tobject);
Procedure Formmousedown (Sender:tobject; Button:tmousebutton;
Shift:tshiftstate; X, Y:integer);
Procedure Formmousemove (Sender:tobject; Shift:tshiftstate; X, Y:integer);
Procedure Formmouseup (Sender:tobject; Button:tmousebutton;
Shift:tshiftstate; X, Y:integer);
Procedure Formcreate (Sender:tobject);
End
Var
Form1:tform1;
Implementation
{$R *.DFM}
Uses Gdipobj,gdipapi;
Var
Pts:array of Tgppoint;
Ptn:integer =-1;
F:boolean;
Procedure Tform1.formcreate (Sender:tobject);
Begin
Text: = ' Hold CTRL key to add point ';
End
Procedure Tform1.formpaint (Sender:tobject);
Var
G:tgpgraphics;
P:tgppen;
I:integer;
Begin
G: = Tgpgraphics.create (Canvas.handle);
P: = Tgppen.create (aclred, 1);
G.clear (Aclwhite);
G.drawbeziers (P, Pgppoint (pts), Length (pts));
P.setcolor (Aclblue);
For I: = Low (pts) to High (PTS) do
G.drawrectangle (P, Makerect, Rect (pts[i). X-2, Pts[i]. Y-2, Pts[i]. X+2, pts [i]. y+2)));
G.free;
P.free;
End
Procedure Tform1.formmousedown (Sender:tobject; Button:tmousebutton;
Shift:tshiftstate; X, Y:integer);
Begin
F: = True;
End
Procedure Tform1.formmousemove (Sender:tobject; Shift:tshiftstate; X
Y:integer);
Var
R:trect;
I:integer;
Begin
If F Then
Begin
If PTN =-1 then Exit;
PTS[PTN]. x: = x;
PTS[PTN]. Y: = y;
Repaint;
End ELSE begin
PTN: =-1;
Cursor: = Crdefault;
For I: = Low (pts) to High (PTS) do
Begin
R: = Rect (Pts[i]. X-2, Pts[i]. Y-2, Pts[i]. X+2, Pts[i]. Y+2);
If PtInRect (R, point (X, Y)) then
Begin
PTN: = i;
Cursor: = Crhandpoint;
End
End
End
End
Procedure Tform1.formmouseup (Sender:tobject; Button:tmousebutton;
Shift:tshiftstate; X, Y:integer);
Begin
F: = False;
If Ssctrl in Shift then
Begin
SetLength (pts, Length (pts) +1);
Pts[high (pts)]. x: = x;
Pts[high (pts)]. Y: = y;
Canvas.Pen.Color: = Clblue;
Canvas.rectangle (X-2, Y-2, x+2, y+2);
{When points are 3*n+1}
If Length (pts) MoD 3 = 1 then Repaint;
End
End
End.
Form file:object Form1: TForm1
Left = 0
Top = 0
Caption = 'Form1'
ClientHeight = 188
ClientWidth = 254
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'Tahoma'
Font.Style = []
OldCreateOrder = False
Position = poDesktopCenter
OnCreate = FormCreate
OnMouseDown = FormMouseDown
OnMouseMove = FormMouseMove
OnMouseUp = FormMouseUp
OnPaint = FormPaint
PixelsPerInch = 96
TextHeight = 13
end