ITChart Draw() Exceptions

TeeChart for ActiveX, COM and ASP
Post Reply
TMECHAM
Newbie
Newbie
Posts: 20
Joined: Tue Aug 17, 2004 4:00 am

ITChart Draw() Exceptions

Post by TMECHAM » Thu Apr 07, 2005 7:14 pm

I am calling the TChart Draw(DC, Left, Top, Right, Bottom: Integer) method and I see a range check error, sometimes. It is like I get 3 exceptions and then it draws properly. I saw a similar bug reported with printing, and wonder if this isn't a related issue.

Code: Select all

   CRect rect = get_window_rect();
   CDC *dc = parent->GetWindowDC();
   CDC memdc;
   memdc.CreateCompatibleDC(dc);
   if(cached_bmp == 0 ||
     (bmp_width != rect.Width() || bmp_height != rect.Height()))
   {
      if(cached_bmp)
      {
         cached_bmp->DeleteObject();
         delete cached_bmp;
      }
      cached_bmp = new CBitmap;
      bmp_width = rect.Width();
      bmp_height = rect.Height();
      cached_bmp->CreateCompatibleBitmap(dc,bmp_width,bmp_height);
   }
   CBitmap *old_bmp = memdc.SelectObject(cached_bmp);
   try
   {
      Draw(reinterpret_cast<long>(memdc.m_hDC),0,0,rect.Width(),rect.Height());
   }
   catch(COleDispatchException *e)
   {
      if(cached_bmp)
      {
         cached_bmp->DeleteObject();
         delete cached_bmp;
         cached_bmp = 0;
      }
      e->Delete();
      trace("TChart::draw() catch(COleDispatchException)");
   }
   catch(COleException *e)
   {
      if(cached_bmp)
      {
         cached_bmp->DeleteObject();
         delete cached_bmp;
         cached_bmp = 0;
      }
      e->Delete();
      trace("TChart::draw() catch(COleException)");
   }
   memdc.SelectObject(old_bmp);
   ReleaseDC(&memdc);
   ReleaseDC(dc);

Pep
Site Admin
Site Admin
Posts: 3277
Joined: Fri Nov 14, 2003 5:00 am
Contact:

Post by Pep » Thu Apr 14, 2005 8:36 pm

Hi,

I've tried to reproduce the problem here using the Draw() method, but it does not give me any error using the latest v7.03. Which TeeChart Pro version are you using ? Also, could you please post an example into the news://steema.net/steema.public.attachments newsgroup with which I can reproduce the problem "as is" here ?

TMECHAM
Newbie
Newbie
Posts: 20
Joined: Tue Aug 17, 2004 4:00 am

Post by TMECHAM » Thu Apr 21, 2005 8:31 pm

Hi Josep,

I am using the latest version. I have sent a project to the attachments group per your request. It is a dialog app that loads a .tee file. All you have to do is resize the dialog to see the exceptions.

GL

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 Apr 22, 2005 3:05 pm

Hi TMECHAM,

I've tested the application you sent and it works fine here for me.

Which Visual C++, operating system, graphic card, ... are you using? Can you run this application in another machine to see if it works there?
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

TMECHAM
Newbie
Newbie
Posts: 20
Joined: Tue Aug 17, 2004 4:00 am

Post by TMECHAM » Fri Apr 22, 2005 4:23 pm

I have reproduced it on both of my development machines:

PC#1 - WinXP SP2, VC++.Net 2003, NVIDIA GeForce FX 5200

PC #2 - W2K SP4, VC++.Net 2002, Matrox G450 DualHead

I see the exceptions on load about 1 in 4.

When I resize the dialog I see them every repaint event.

I'm catching the exceptions and just dumping them out to the debug console ...

First-chance exception at 0x7c81eb33 in tchart_test.exe: Microsoft C++ exception: COleDispatchException @ 0x0012ee78.
CTchart1::draw() catch(COleDispatchException)
First-chance exception at 0x7c81eb33 in tchart_test.exe: 0x0EEDFADE: 0xeedfade.
First-chance exception at 0x7c81eb33 in tchart_test.exe: Microsoft C++ exception: COleDispatchException @ 0x0012ee78.
CTchart1::draw() catch(COleDispatchException)
First-chance exception at 0x7c81eb33 in tchart_test.exe: 0x0EEDFADE: 0xeedfade.

TMECHAM
Newbie
Newbie
Posts: 20
Joined: Tue Aug 17, 2004 4:00 am

Post by TMECHAM » Fri May 20, 2005 7:25 pm

I'm still seeing this with the latest version. Is there anything else I can do to help squash this bug?

Thanks

Pep
Site Admin
Site Admin
Posts: 3277
Joined: Fri Nov 14, 2003 5:00 am
Contact:

Post by Pep » Mon May 23, 2005 10:05 am

Hi,

I've been reviewing the sample you sent us, and I think it's not a problem related with the Chart, if you comment the following line :
the_chart.ShowWindow(SW_HIDE);
it works fine. I think the problem is related on how you're creating the bmp.

TMECHAM
Newbie
Newbie
Posts: 20
Joined: Tue Aug 17, 2004 4:00 am

Post by TMECHAM » Tue May 24, 2005 3:30 pm

I've resubmitted another project to the attachments group. I have simplified my code so that the problem should be easier to see. I have created 2 windows, one that has the chart and another that calls the Draw method of the chart. I am drawing into the same DC that gets passed into the Draw method and my draw code always works, so I know the DC and Bitmap associated with it are valid. The question is why is the chart throwing an exception from the Draw method a majority of the time?

With my old example, when you comment out the ShowWindow(SW_HIDE) code, the draw code that generated the exception was never being called because the paint rect was 0.

I hope this new code will help.

Thanks,
Tyler

Post Reply