EOutofResource when zooming tchart
Posted: Mon Apr 18, 2005 6:15 am
I place about 20 to 30 TChart object. And then i call scaleby to zoom each tchart object to 400%. Then i get EOutofResource error when i scrolling up or scrolling down. How to solve it?
my test code is like this:
//test.h
//---------------------------------------------------------------------------
class TForm1 : public TForm
{
__published: // IDE-managed Components
TButton *Button1;
TButton *Button2;
void __fastcall Button1Click(TObject *Sender);
void __fastcall FormCreate(TObject *Sender);
void __fastcall FormDestroy(TObject *Sender);
void __fastcall Button2Click(TObject *Sender);
private: // User declarations
public: // User declarations
__fastcall TForm1(TComponent* Owner);
};
//---------------------------------------------------------------------------
extern PACKAGE TForm1 *Form1;
//---------------------------------------------------------------------------
//test.cpp
TForm1 *Form1;
TList *pLst;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
VertScrollBar->Range = 1123;
HorzScrollBar->Range = 794;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
int i; TChart *pObj;
for(i = 0; i < 10; i++)
{
pLst->Add(new TChart(this));
pObj = (TChart*) pLst->Items[pLst->Count-1];
pObj->Parent = this;
pObj->Left = 50 + ((i) * 20);
pObj->Top = 50 + ((i) * 20);
}
pObj = NULL;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormCreate(TObject *Sender)
{
pLst = new TList();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormDestroy(TObject *Sender)
{
int i;
while(pLst->Count > 0)
{
pLst->Delete(pLst->Count - 1);
}
delete pLst;
pLst = NULL;
}
//---------------------------------------------------------------------------
//Zoom to 400%
void __fastcall TForm1::Button2Click(TObject *Sender)
{
int i; TChart *pObj;
VertScrollBar->Range *= 4;
HorzScrollBar->Range *= 4;
for(i = 0; i < pLst->Count; i++)
{
pObj = (TChart*) pLst->Items;
pObj->ScaleBy(400,100);
pObj->Top *= 4;
pObj->Left *= 4;
}
pObj = NULL;
}
//---------------------------------------------------------------------------
Thank you
my test code is like this:
//test.h
//---------------------------------------------------------------------------
class TForm1 : public TForm
{
__published: // IDE-managed Components
TButton *Button1;
TButton *Button2;
void __fastcall Button1Click(TObject *Sender);
void __fastcall FormCreate(TObject *Sender);
void __fastcall FormDestroy(TObject *Sender);
void __fastcall Button2Click(TObject *Sender);
private: // User declarations
public: // User declarations
__fastcall TForm1(TComponent* Owner);
};
//---------------------------------------------------------------------------
extern PACKAGE TForm1 *Form1;
//---------------------------------------------------------------------------
//test.cpp
TForm1 *Form1;
TList *pLst;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
VertScrollBar->Range = 1123;
HorzScrollBar->Range = 794;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
int i; TChart *pObj;
for(i = 0; i < 10; i++)
{
pLst->Add(new TChart(this));
pObj = (TChart*) pLst->Items[pLst->Count-1];
pObj->Parent = this;
pObj->Left = 50 + ((i) * 20);
pObj->Top = 50 + ((i) * 20);
}
pObj = NULL;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormCreate(TObject *Sender)
{
pLst = new TList();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormDestroy(TObject *Sender)
{
int i;
while(pLst->Count > 0)
{
pLst->Delete(pLst->Count - 1);
}
delete pLst;
pLst = NULL;
}
//---------------------------------------------------------------------------
//Zoom to 400%
void __fastcall TForm1::Button2Click(TObject *Sender)
{
int i; TChart *pObj;
VertScrollBar->Range *= 4;
HorzScrollBar->Range *= 4;
for(i = 0; i < pLst->Count; i++)
{
pObj = (TChart*) pLst->Items;
pObj->ScaleBy(400,100);
pObj->Top *= 4;
pObj->Left *= 4;
}
pObj = NULL;
}
//---------------------------------------------------------------------------
Thank you