TCursorTool Bug?
Posted: Fri Nov 21, 2008 5:25 am
Hello,
I add a CursorTool at XValue that was entered at Edit1,
But there are two CursorTool being painted and at the wrong position.
Please take a look at the picture below.
[Img]
http://img1.freep.cn/p.aspx?u=v20_img1_ ... 103843.jpg
[/Img]
I have upload the source and application.
BTW: BCB6.0,Teechart6.01
Unit.h
Unit.cpp
[/img]
I add a CursorTool at XValue that was entered at Edit1,
But there are two CursorTool being painted and at the wrong position.
Please take a look at the picture below.
[Img]
http://img1.freep.cn/p.aspx?u=v20_img1_ ... 103843.jpg
[/Img]
I have upload the source and application.
BTW: BCB6.0,Teechart6.01
Unit.h
Code: Select all
//---------------------------------------------------------------------------
#ifndef Unit1H
#define Unit1H
//---------------------------------------------------------------------------
#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
#include "ImaPoint.hpp"
#include <Chart.hpp>
#include <ExtCtrls.hpp>
#include <Graphics.hpp>
#include <Series.hpp>
#include <TeEngine.hpp>
#include <TeeProcs.hpp>
#include "TeeTools.hpp"
#include "TeeEdit.hpp"
//---------------------------------------------------------------------------
class TForm1 : public TForm
{
__published: // IDE-managed Components
TChart *Chart1;
TFastLineSeries *Series1;
TFastLineSeries *Series2;
TEdit *Edit1;
TLabel *Label1;
void __fastcall Chart1AfterDraw(TObject *Sender);
void __fastcall Edit1KeyUp(TObject *Sender, WORD &Key,
TShiftState Shift);
private: // User declarations
bool bDrawText;
public: // User declarations
__fastcall TForm1(TComponent* Owner);
TCursorTool *curLine;
};
//---------------------------------------------------------------------------
extern PACKAGE TForm1 *Form1;
//---------------------------------------------------------------------------
#endif
Code: Select all
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
Chart1->BottomAxis->SetMinMax(1,100);
Chart1->LeftAxis->SetMinMax(1,100);
Chart1->Axes->Bottom->Grid->Visible = false;
Chart1->Axes->Left->Grid->Visible = false;
}
void __fastcall TForm1::Chart1AfterDraw(TObject *Sender)
{
if(bDrawText)
{
int X0 = Chart1->Axes->Bottom->CalcXPosValue( StrToFloat(Edit1->Text) );
int Y0 = Chart1->Axes->Left->CalcYPosValue(50);
curLine = new TCursorTool(Series1);
curLine->Pen->Style = psDot;
curLine->Pen->Color = clGreen;
curLine->ParentChart = Chart1;
curLine->Series = Series1;
curLine->Style = cssVertical;
curLine->XValue = X0;
Chart1->Canvas->TextOutA(X0,Y0,"Test");
}
}
void __fastcall TForm1::Edit1KeyUp(TObject *Sender, WORD &Key,
TShiftState Shift)
{
if(Key == 13)
{
bDrawText = true;
Chart1->Draw();
bDrawText = false;
}
}