"Error reading Tchart->OnAfterDraw" Exception
Posted: Thu Nov 20, 2008 1:18 pm
When I run the following codes ,"Error reading Tchart->OnAfterDraw" application Exception is showed.
Run the application ,
add points to chart by "btnAddPointClick(TObject *Sender) ",
push the "Save para" button to save the .tee file(btnSaveparaClick),
the "OK" what were canvased disappeared.
Then close the application ,open it again, the application Exception is showed.
Unit.h
Unit.cpp
Run the application ,
add points to chart by "btnAddPointClick(TObject *Sender) ",
push the "Save para" button to save the .tee file(btnSaveparaClick),
the "OK" what were canvased disappeared.
Then close the application ,open it again, the application Exception is showed.
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;
TButton *btnSavepara;
TChartEditor *ChartEditor1;
TButton *btnLoadPara;
TButton *btnEditchart;
TButton *btnAddPoint;
TFastLineSeries *Series2;
TFastLineSeries *Series1;
void __fastcall btnSaveparaClick(TObject *Sender);
void __fastcall btnEditchartClick(TObject *Sender);
void __fastcall btnAddPointClick(TObject *Sender);
void __fastcall btnLoadParaClick(TObject *Sender);
void __fastcall Chart1AfterDraw(TObject *Sender);
private: // User declarations
bool bDrawText;
public: // User declarations
__fastcall TForm1(TComponent* Owner);
};
//---------------------------------------------------------------------------
extern PACKAGE TForm1 *Form1;
//---------------------------------------------------------------------------
#endif
Code: Select all
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "Unit1.h"
#include "TeeStore.hpp"
#include "EditChar.hpp"
#include "TeeEditPRO.hpp"
#pragma link "TeeEditPRO"
//---------------------------------------------------------------------------
#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->BottomAxis->Logarithmic=true;
Chart1->LeftAxis->Logarithmic=true;
bDrawText = false;
if(FileExists("d:\\a.tee"))
{
LoadChartFromFile(Chart1,"d:\\a.tee");
}
}
//Load Tchart Parameters
void __fastcall TForm1::btnSaveparaClick(TObject *Sender)
{
SaveChartToFile(Chart1,"d:\\a.tee",false,false);
}
//Edit chart
void __fastcall TForm1::btnEditchartClick(TObject *Sender)
{
EditChart(Form1,Chart1);
}
//Add sample points
void __fastcall TForm1::btnAddPointClick(TObject *Sender)
{
bDrawText = true;
Chart1->Draw();
bDrawText = false;
}
//Load chart Parameters
void __fastcall TForm1::btnLoadParaClick(TObject *Sender)
{
//
}
void __fastcall TForm1::Chart1AfterDraw(TObject *Sender)
{
int X0 = Chart1->Axes->Bottom->CalcXPosValue(10);
int Y0 = Chart1->Axes->Left->CalcYPosValue(50);
if(bDrawText )
{
for(int i=0;i<5;i++)
{
Chart1->Canvas->TextOutA(X0,Y0,"OK");
X0 +=10;
Y0 +=10;
}
}
}
//---------------------------------------------------------------------------