This example effect chart:
Code files:Unit Unit1;
Interface
Uses
Windows, Messages, sysutils, variants, Classes, Graphics, Controls, Forms,
Dialogs, Stdctrls, Extctrls;
Type
TForm1 = Class (Tform)
Combobox1:tcombobox;
Combobox2:tcombobox;
Combobox3:tcombobox;
Combobox4:tcombobox;
Procedure Formcreate (Sender:tobject);
Procedure Formpaint (Sender:tobject);
Procedure Combobox1change (Sender:tobject);
Procedure Combobox2change (Sender:tobject);
Procedure Combobox3change (Sender:tobject);
Procedure Combobox4change (Sender:tobject);
End
Var
Form1:tform1;
Implementation
{$R *.DFM}
Uses Gdipobj, Gdipapi, Typinfo;
var Startcap,endcap,dashcap:integer;
Procedure Tform1.formcreate (Sender:tobject);
Var
I:integer;
Begin
Combobox1.text: = ' dotted style ';
Combobox2.text: = ' beginning line cap ';
Combobox3.text: = ' middle line cap ';
Combobox4.text: = ' finish line cap ';
For I: = 0 to 5 do
COMBOBOX1.ITEMS.ADD (Getenumname (TypeInfo (Tdashstyle), i));
COMBOBOX2.ITEMS.ADD (' Linecapflat ');
COMBOBOX2.ITEMS.ADD (' Linecapsquare ');
COMBOBOX2.ITEMS.ADD (' Linecapround ');
COMBOBOX2.ITEMS.ADD (' Linecaptriangle ');
COMBOBOX2.ITEMS.ADD (' Linecapnoanchor ');
COMBOBOX2.ITEMS.ADD (' Linecapsquareanchor ');
COMBOBOX2.ITEMS.ADD (' Linecaproundanchor ');
COMBOBOX2.ITEMS.ADD (' Linecapdiamondanchor ');
COMBOBOX2.ITEMS.ADD (' Linecaparrowanchor ');
Combobox3.items: = Combobox2.items;
Combobox4.items: = Combobox2.items;
End
Procedure Tform1.formpaint (Sender:tobject);
Const
COLORARR:ARRAY[0..2] of Tgpcolor = (aclred, Aclgreen, Aclblue);
Var
G:tgpgraphics;
P:tgppen;
X1,x2,y:integer;
I:integer;
Begin
G: = Tgpgraphics.create (Canvas.handle);
P: = tgppen.create ($FF 000000, 16);
P.setdashstyle (Tdashstyle (Combobox1.itemindex));
P.setlinecap (StartCap, Endcap, DashCap);
X1: = 50;
x2: = ClientWidth-50;
Y: = 60;
For I: = 0 to 2 do
Begin
P.setcolor (Colorarr[i]);
G.drawline (P, x1, y, x2, y);
Inc. (y, 40);
End
P.free;
G.free;
End
Procedure Tform1.combobox1change (Sender:tobject);
Begin
Repaint;
End
Procedure Tform1.combobox2change (Sender:tobject);
Var
I:integer;
Begin
I: = 0;
Case Tcombobox (Sender). ItemIndex of
0:I: = Linecapflat;
1:I: = Linecapsquare;
2:I: = Linecapround;
3:I: = Linecaptriangle;
4:I: = Linecapnoanchor;
5:I: = Linecapsquareanchor;
6:I: = Linecaproundanchor;
7:I: = Linecapdiamondanchor;
8:I: = Linecaparrowanchor;
9:I: = Linecapcustom;
10:I: = Linecapanchormask;
End
If Tcombobox (Sender) = ComboBox2 then startcap: = i;
If Tcombobox (Sender) = ComboBox3 then dashcap: = i;
If Tcombobox (Sender) = ComboBox4 then endcap: = i;
Repaint;
End
Procedure Tform1.combobox3change (Sender:tobject);
Begin
Combobox2change (Sender);
End
Procedure Tform1.combobox4change (Sender:tobject);
Begin
Combobox2change (Sender);
End
End.