"Error reading Tchart->OnAfterDraw" Exception

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
wwp3321
Newbie
Newbie
Posts: 60
Joined: Wed Jul 02, 2003 4:00 am

"Error reading Tchart->OnAfterDraw" Exception

Post by wwp3321 » 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

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
Unit.cpp

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;
   }
}
}
//---------------------------------------------------------------------------



Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Thu Nov 20, 2008 1:54 pm

Hello wwp3321,

Have you tried implementing OnAfterDraw event like this?

Code: Select all

void __fastcall TForm1::Chart1AfterDraw(TObject *Sender)
{
	if(bDrawText )
	{
		int X0 = Chart1->Axes->Bottom->CalcXPosValue(10);
		int Y0 = Chart1->Axes->Left->CalcYPosValue(50);

		for(int i=0;i<5;i++)
		{
			Chart1->Canvas->TextOutA(X0,Y0,"OK");
			X0 +=10;
			Y0 +=10;
		}
	}
}
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

wwp3321
Newbie
Newbie
Posts: 60
Joined: Wed Jul 02, 2003 4:00 am

Post by wwp3321 » Fri Nov 21, 2008 12:37 am

narcis wrote:Hello wwp3321,

Have you tried implementing OnAfterDraw event like this?

Code: Select all

void __fastcall TForm1::Chart1AfterDraw(TObject *Sender)
{
	if(bDrawText )
	{
		int X0 = Chart1->Axes->Bottom->CalcXPosValue(10);
		int Y0 = Chart1->Axes->Left->CalcYPosValue(50);

		for(int i=0;i<5;i++)
		{
			Chart1->Canvas->TextOutA(X0,Y0,"OK");
			X0 +=10;
			Y0 +=10;
		}
	}
}

Yes, I have tried ,but still get "Error reading Tchart->OnAfterDraw" application Exception.

[img]
http://img1.freep.cn/p.aspx?u=v20_img1_ ... 103843.jpg
[/img]
Last edited by wwp3321 on Fri Nov 21, 2008 1:05 am, edited 1 time in total.

wwp3321
Newbie
Newbie
Posts: 60
Joined: Wed Jul 02, 2003 4:00 am

Post by wwp3321 » Fri Nov 21, 2008 12:39 am

I saved the "a.tee" file as .txt file, it includes "OnAfterDraw = Chart1AfterDraw". I think Exception showed when Chart read this value .

Would you please try to compile my source posted ?
Thank you!

wwp3321
Newbie
Newbie
Posts: 60
Joined: Wed Jul 02, 2003 4:00 am

Post by wwp3321 » Fri Nov 21, 2008 1:54 am

Another question

The "SaveChartToFile()" method erased those "OK"s. :shock:

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Fri Nov 21, 2008 9:32 am

Hi wwp3321,
Yes, I have tried ,but still get "Error reading Tchart->OnAfterDraw" application Exception.
I'm not able to reproduce this here using v8.04. Should I follow any specific steps to reproduce it?
The "SaveChartToFile()" method erased those "OK"s
Yes, custom drawing is not exported with charts and you will have to draw it again after saving the chart file:

Code: Select all

//Load Tchart Parameters
void __fastcall TForm1::btnSaveparaClick(TObject *Sender)
{
	SaveChartToFile(Chart1,"c:\\temp\\a.tee",false,false);
	bDrawText = true;
	Chart1->Draw();
	bDrawText = false;
}
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

wwp3321
Newbie
Newbie
Posts: 60
Joined: Wed Jul 02, 2003 4:00 am

Post by wwp3321 » Fri Nov 21, 2008 10:01 am

narcis wrote:Hi wwp3321,
Yes, I have tried ,but still get "Error reading Tchart->OnAfterDraw" application Exception.
I'm not able to reproduce this here using v8.04. Should I follow any specific steps to reproduce it?
Run the application ,
add points to chart by "btnAddPointClick(TObject *Sender) ",
push the "Save para" button to save the .tee file(btnSaveparaClick),

Then close the application ,open it again, the application Exception is showed.

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Fri Nov 21, 2008 10:18 am

Hi wwp3321,

Thanks for the information but I'm not able to reproduce this here using v8.04. You could try downloading fully functional evaluation version at the URL below and try in a different machine (or same machine with v6 installed) if it solves the problem at your end.

http://www.steema.com/downloads/form_tch_vcl.html

Please notice that TeeChart Pro v7 VCL was released on early 2004 and since mid-2007 v8 is the current TeeChart version.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

wwp3321
Newbie
Newbie
Posts: 60
Joined: Wed Jul 02, 2003 4:00 am

Post by wwp3321 » Fri Nov 21, 2008 10:23 am

Would you please try with Teechart 6.01 and BCB6.0

wwp3321
Newbie
Newbie
Posts: 60
Joined: Wed Jul 02, 2003 4:00 am

Post by wwp3321 » Sat Nov 22, 2008 10:04 am

I have tried at other computers,but get the same application error...
BCB6.0,Teechart6.01
WinXP sp2

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Mon Nov 24, 2008 8:16 am

Hi wwp3321,

Thanks for the information. We could reproduce the issue here using BCB6 and TeeChart V6.01. We can also confirm this works fine using v8.

We are investigating the issue and will get back to you when we have further news.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Mon Nov 24, 2008 11:12 am

Hi wwp3321,

Before exporting the chart you should set all events to null and after importing it assign them again, for example:

Code: Select all

//Load Tchart Parameters
void __fastcall TForm1::btnSaveparaClick(TObject *Sender)
{
        Chart1->OnAfterDraw=NULL;
	SaveChartToFile(Chart1,"c:\\temp\\a.tee",false,true);
	bDrawText = true;
	Chart1->Draw();
	bDrawText = false;
}

//Load chart Parameters
void __fastcall TForm1::btnLoadParaClick(TObject *Sender)
{
        if(FileExists("c:\\temp\\a.tee"))
	{
          LoadChartFromFile(dynamic_cast<TCustomChart*>(Chart1),"c:\\temp\\a.tee");
          Chart1->OnAfterDraw=Chart1AfterDraw;
	}
}
TeeChart v8 VCL does this automatically.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Post Reply