Page 1 of 2

EOutofResource when zooming tchart

Posted: Mon Apr 18, 2005 6:15 am
by 9235196
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

Posted: Mon Apr 18, 2005 8:11 am
by narcis
Hi Herman,

Which TeeChart version are you using? I tested your code using latest v7.04 version and creating up to 40 TChart objects without getting the error you report.

Posted: Mon Apr 18, 2005 9:44 am
by 9235196
I'm using version 7.04v.

Thank you

Posted: Mon Apr 18, 2005 10:23 am
by narcis
Hi Herman,

This is also the version I used. Could you please send us a test project we can run "as-is" to reproduce the problem here? You can post it at [url]news://www.steema.net/steema.public.attachments[/url] newsgroup.

Thanks in advance.

Posted: Tue Apr 19, 2005 1:29 am
by 9235196
I have receive your code.
I test it like this:
1. Re-compile
2. Click add
3.Click zoom --> then error comes :"EOutofResource"

Do i need to change the max heap or stack size in BCB project options?

My computer is:
Win XP Home Edition v2002 sp2
Pentium 3 997MHz
512MB RAM

Posted: Tue Apr 19, 2005 1:51 am
by 9235196
I have also tested the code on different computer with better spec, and same thing happend again.

1.compile
2.click add
3.click zoom -> "EOutofResource"

Both computer use TChart v7.04
Another thing is both computer also use MTXVec and DSP from DewResearch.

Posted: Tue Apr 19, 2005 3:16 am
by 9235196
Can you send me the exe file?
The project that build using your compiler.

Thank you

Herman

Posted: Tue Apr 19, 2005 7:31 am
by narcis
Hi Herman,

It's really strange, I've already sent the .exe you request could you please run it and let me know how it went? I'm running in the following specs:

Win 2003 Server Ent + SP1.
Pentium 4 3.2Ghz.
1 GB RAM

Also which BCB6 version are you using? I use BCB6 Enterprise with update 4 installed (latest available).

Posted: Tue Apr 19, 2005 8:20 am
by narcis
Hi Herman,

As I suggested on my previous post please install ALL BCB6 official updates as it's mandatory for TeeChart.

Posted: Tue Apr 19, 2005 9:32 am
by 9235196
I'm using BCB6 Professional
Win XP Home Edition sp2 Chinese Edition.
I just download and install the latest update version 4.

Re-test Project1.exe , problem still exist

Posted: Tue Apr 19, 2005 9:59 am
by narcis
Hi Herman,

Have you tried the second .exe file I sent you? The 2nd one is compiled without run-time packages and shouldn't depend on your BCB6 installation files.

Posted: Tue Apr 19, 2005 10:09 am
by 9235196
Yes, I did.
And it failed too

Posted: Wed Apr 20, 2005 3:32 am
by 9235196
Today i tested the exe file (built without run-time packages) on computer with spec:
Win xp professional english edition sp2
512 MBRAM
BCB6 Enterprise edition

And problem still not solved.

Posted: Wed Apr 20, 2005 6:28 am
by 9235196
When i debugging it, it stops in

File : Graphics.pas

procedure GDIError;
var
ErrorCode: Integer;
Buf: array [Byte] of Char;
begin
ErrorCode := GetLastError;
if (ErrorCode <> 0) and (FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, nil,
ErrorCode, LOCALE_USER_DEFAULT, Buf, sizeof(Buf), nil) <> 0) then
raise EOutOfResources.Create(Buf)
else
OutOfResources;
end;

Thank you

Posted: Wed Apr 20, 2005 8:38 am
by narcis
Hi Herman,

After testing the application on several machines I was able to reproduce the problem in one of them which is very similar to mine. We concluded it would be related to internal bitmap.

So, is it absolutely necessary to zoom/update 30 charts? I mean, perhaps the solution would be to set each chart autorepaint to false, do the zoom (for all charts) and then refresh charts. This worked on the "problematic" machine.

I've already sent you the test application I created with those changes applied, could you please check if this works for you?

Another thing which wouldn't hurt would be upgrading your graphical card drivers which can be the cause of this problem.