Chart drawing fails after loading other 3rd party DLL

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
j-o-l
Newbie
Newbie
Posts: 14
Joined: Wed Jun 14, 2006 12:00 am

Chart drawing fails after loading other 3rd party DLL

Post by j-o-l » Fri Jul 14, 2006 11:45 am

Hi!,

I'm getting a strange exception when trying to draw a chart after loading other 3rd party DLL with CoInitialize and LoadLibrary. The place where the chart should appear is left blank with red cross over it and following exception is thrown:

Code: Select all

System.ArithmeticException: Overflow or underflow in the arithmetic operation.
   at System.Drawing.Font.Initialize(FontFamily family, Single emSize, FontStyle style, GraphicsUnit unit, Byte gdiCharSet, Boolean gdiVerticalFont)
   at System.Drawing.Font.Initialize(String familyName, Single emSize, FontStyle style, GraphicsUnit unit)
   at System.Drawing.Font..ctor(String familyName, Single emSize, FontStyle style)
   at Steema.TeeChart.Drawing.ChartFont.get_DrawingFont()
   at Steema.TeeChart.Drawing.Graphics3DGdiPlus.MeasureString(ChartFont f, String text)
   at Steema.TeeChart.Drawing.Graphics3D.TextHeight(String text)
   at Steema.TeeChart.Drawing.Graphics3D.get_FontHeight()
   at Steema.TeeChart.Title.Draw(Graphics3D g, Rectangle& rect)
   at Steema.TeeChart.Title.DoDraw(Graphics3D g, Rectangle& rect, Boolean CustomOnly)
   at Steema.TeeChart.Chart.DrawTitleFoot(Rectangle& rect, Boolean CustomOnly)
   at Steema.TeeChart.Chart.DrawTitlesAndLegend(Graphics g, Rectangle& tmp, Boolean BeforeSeries)
   at Steema.TeeChart.Chart.InternalDraw(Graphics g, Boolean noTools)
   at Steema.TeeChart.Chart.InternalDraw(Graphics g)
   at Steema.TeeChart.TChart.Draw(Graphics g)
   at Steema.TeeChart.TChart.OnPaint(PaintEventArgs pe)
   at System.Windows.Forms.Control.PaintWithErrorHandling(PaintEventArgs e, Int16 layer, Boolean disposeEventArgs)
   at System.Windows.Forms.Control.WmPaint(Message& m)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.ControlNativeWindow.OnMessage(Message& m)
   at System.Windows.Forms.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
I know that it may be impossible to say what the exact cause for this is, but does anyone have any ideas on what might be causing this behavior?
I'm using Visual C++.NET 2003.

Thanks in advance!

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 Jul 14, 2006 11:53 am

Hi j-o-l,

Is the chart drawn correctly without loading this 3rd party DLL?

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
Image Image Image Image Image Image
Instructions - How to post in this forum

j-o-l
Newbie
Newbie
Posts: 14
Joined: Wed Jun 14, 2006 12:00 am

Post by j-o-l » Fri Jul 14, 2006 12:03 pm

narcis wrote:Hi j-o-l,

Is the chart drawn correctly without loading this 3rd party DLL?

Thanks in advance.
Yes, everything works fine before I execute CoInitialize(NULL) and LoadLibrary(...).

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 Jul 17, 2006 10:32 am

Hi j-o-l,

Some time ago another customer reported something very similar, could you please have a look at that customer's message?

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
Image Image Image Image Image Image
Instructions - How to post in this forum

j-o-l
Newbie
Newbie
Posts: 14
Joined: Wed Jun 14, 2006 12:00 am

Post by j-o-l » Mon Jul 17, 2006 10:56 am

Hi,

I tried setting all the titles invisible and now charts seem to be working again. So the problem seems to be related to fonts somehow.
I tried unloading that other DLL before drawing any charts but I still got the same exception...

narcis wrote:Hi j-o-l,

Some time ago another customer reported something very similar, could you please have a look at that customer's message?

Thanks in advance.

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

Post by Narcís » Tue Jul 18, 2006 11:36 am

Hi j-o-l,

The fonts work fine in TeeChart and that it's the other dll that seems to be making a mess of them. If you take out all references to TChart but use the other dll, can you use fonts correctly?
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

j-o-l
Newbie
Newbie
Posts: 14
Joined: Wed Jun 14, 2006 12:00 am

Post by j-o-l » Tue Jul 18, 2006 11:51 am

Hi,

I'm able to use labels etc. components normally after loading that DLL, that exception is thrown only when I'm trying to draw a chart with some text in it (titles etc..).

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

Post by Narcís » Wed Jul 19, 2006 10:58 am

Hi j-o-l,

How about puting a panel on a form with your other dll, override the OnPaint event and use graphics.TextOut with a new font to draw a string to the canvas? You can either override the OnPaint method, which would mean deriving from the Panel class, or you can put the font creation/string drawing code in the Panel's paint event.
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

j-o-l
Newbie
Newbie
Posts: 14
Joined: Wed Jun 14, 2006 12:00 am

Post by j-o-l » Tue Jul 25, 2006 10:39 am

Are you referring to System::Drawing::Graphics? That class doesn't have TextOut but DrawString worked when I tried that.. So GDI+ seems to be working fine (but TeeChart is using GDI to draw those texts?).
I know that that 3rd party dll I'm loading includes some Borland runtime libraries & VCL components, maybe those have something to do with the problem?

I accidentally found out that adding following lines after the dll loading charts seem to be drawing correctly again:

Code: Select all

Graphics* gr = CreateGraphics();
gr->Dispose();
try {
IntPtr hdc = gr->GetHdc();
} catch(...) {}
... but I have no idea why that seems to fix the problem.
narcis wrote:Hi j-o-l,

How about puting a panel on a form with your other dll, override the OnPaint event and use graphics.TextOut with a new font to draw a string to the canvas? You can either override the OnPaint method, which would mean deriving from the Panel class, or you can put the font creation/string drawing code in the Panel's paint event.

j-o-l
Newbie
Newbie
Posts: 14
Joined: Wed Jun 14, 2006 12:00 am

Post by j-o-l » Wed Jul 26, 2006 10:25 am

Hi,

I now received a new version of that dll with less Borland dependencies and everything seems to be working now.

Post Reply