呵呵!刚好我也做过一个股票分析软件(不过只是自己分析用)^_^
我对于K线图的做法是自己先定义一个新的画笔单元,为此还专门写了一个绘图控件!
下面是一个定义的Draw过程:
procedure DrawLines (Ind:Integer);
Var A:Integer;
RY,Incr:Extended;
Clr:TColor;
ZY:Integer;
Rgn:HRgn;
PrevDef:Boolean;
TempR:TRect;
Ext:Extended;
FuncOK:Boolean;
TP:Array [0..1] of TPoint;
begin
TempR:=Rect (R.Left,R.Top,R.Right+1,R.Bottom+1);
Rgn:=CreateRectRgnIndirect (TempR);
SelectClipRgn (DrawCanvas.Handle,Rgn);
Clr:=FSeries[Ind].Color;
RY:=(R.Bottom-R.Top)/(FVisRect.Y2-FVisRect.Y1);
Incr:=(FVisRect.X2-FVisRect.X1)/(R.Right-R.Left);
XParser.X:=FVisRect.X1;
PrevDef:=False;
with DrawCanvas do
begin
Pen.Style:=psSolid;
Pen.Color:=Clr;
Ext:=0;
ZY:=0;
For A:=R.Left to R.Right do
begin
try
Ext:=XParser.Value;
FuncOK:=not XParser.CalcError;
except
FuncOK:=False;
end;
If FuncOK then
begin
ZY:=R.Bottom-Round((Ext-FVisRect.Y1)*RY);
If NOT PrevDef then
begin
Pixels [A,ZY]:=Clr;
MoveTo (A,ZY);}
TP[0].X:=A;
TP[0].Y:=ZY;
end
else
begin
LineTo (A,ZY);
TP[1].X:=A;
TP[1].Y:=ZY;
PolyLine (TP);
DrawLine (TP[0].X,Tp[0].Y,TP[1].X,TP[1].Y,Clr);
If NOT
(((TP[0].Y<0) AND (TP[1].Y<0)) OR
((TP[0].Y>Height) AND (TP[1].Y>Height))) then
DrawCanvas.PolyLine (TP);
TP[0]:=TP[1];
end;
PrevDef:=True;
end
else
PrevDef:=False;
XParser.X:=XParser.X+Incr;
end; {For A:=R.Left to R.Right}
If PrevDef then
Pixels [R.Right,ZY]:=Clr;
end; {with DrawCanvas}
SelectClipRgn (DrawCanvas.Handle,0);
DeleteObject (Rgn);
end;