Canvas method must be used in the OnAfterDraw event?
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi wwp3321,
Thanks for the information.
I could not get your project working. I guess it's something you set at designtime. However, setting up a new C++ Builder project, dropping a TChart and a TButton into a form, adding 2 series at designtime and using code below, produces a chart very similar to yours and works fine for me here.
Could you please check if this works fine at your end?
Thanks in advance
Thanks for the information.
I could not get your project working. I guess it's something you set at designtime. However, setting up a new C++ Builder project, dropping a TChart and a TButton into a form, adding 2 series at designtime and using code below, produces a chart very similar to yours and works fine for me here.
Could you please check if this works fine at your end?
Code: Select all
//---------------------------------------------------------------------------
void __fastcall TForm3::FormCreate(TObject *Sender)
{
Chart1->BottomAxis->SetMinMax(1,100);
Chart1->LeftAxis->SetMinMax(1,100);
Chart1->BottomAxis->Logarithmic=true;
Chart1->LeftAxis->Logarithmic=true;
}
//---------------------------------------------------------------------------
void __fastcall TForm3::Button1Click(TObject *Sender)
{
int X0 = Chart1->BottomAxis->CalcXPosValue(10);
int Y0 = Chart1->LeftAxis->CalcYPosValue(50);
for (int i = 0; i < 5; i++)
{
Chart1->Canvas->TextOut(X0,Y0,"OK");
X0++;
Y0++;
}
}
//---------------------------------------------------------------------------
Best Regards,
Narcís Calvet / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |
It also didnt work with your codes.
With
I can get one "OK";
With
I get nothing ,even one "OK";
With
Code: Select all
int X0 = Chart1->Axes->Bottom->CalcXPosValue(10);
int Y0 = Chart1->Axes->Left->CalcYPosValue(50);
Chart1->Canvas->TextOutA(X0,Y0,"OK");
With
Code: Select all
int X0 = Chart1->Axes->Bottom->CalcXPosValue(10);
int Y0 = Chart1->Axes->Left->CalcYPosValue(50);
for(int i=0;i++;i<5)
{
Chart1->Canvas->TextOutA(X0,Y0,"OK");
X0 ++;
Y0 ++;
}
I paint all the source here.
Unit.h
Unit.cpp
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
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;
}
//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)
{
Chart1->Draw();
int X0 = Chart1->Axes->Bottom->CalcXPosValue(10);
int Y0 = Chart1->Axes->Left->CalcYPosValue(50);
for(int i=0;i++;i<5)
{
Chart1->Canvas->TextOutA(X0,Y0,"OK");
X0 ++;
Y0 ++;
}
}
//Load chart Parameters
void __fastcall TForm1::btnLoadParaClick(TObject *Sender)
{
if(FileExists("d:\\a.tee"))
{
LoadChartFromFile(Chart1,"d:\\a.tee");
}
}
I am very sorry .
should be
Best Regards
wwp
Now it work well ,but when I resized the form ,I have to Canvas again.
Is there any other way without painting again?
Code: Select all
for(int i=0;i++;i<5)
Code: Select all
for(int i=0;i<5;i++)
wwp
Now it work well ,but when I resized the form ,I have to Canvas again.
Is there any other way without painting again?
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi wwp3321,
As I previously told you, please try enable a flag in btnAddPointClick which it's checked in OnAfterDraw event and do the custom drawing there.
Thanks in advance.
As I previously told you, please try enable a flag in btnAddPointClick which it's checked in OnAfterDraw event and do the custom drawing there.
Thanks in advance.
Best Regards,
Narcís Calvet / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |