Re: Trouble of GDI+ generic error!



Thanks for your reply james,

Regardingon the those managed GDI+ objects(such as Pen, Brush, Font ....),
you're recommended to dispose it rigth after you've finished using it (in a
certain GDI+ function call such as DrawXXX). Generally, you can consider
put the object disposing code at the end of the certain function which
perform a GDI+ task.

In addition, here is a GDI+ FAQ article about when to dispose object:

#Disposing of GDI+ resources
http://www.bobpowell.net/disposing_of_resources.htm

and there are many other useful faq articles on GDI+ there:

http://www.bobpowell.net/faqmain.htm

Hope this also helps.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


This posting is provided "AS IS" with no warranties, and confers no rights.

.



Relevant Pages

  • Re: Trouble of GDI+ generic error!
    ... certain GDI+ function call such as DrawXXX). ... here is a GDI+ FAQ article about when to dispose object: ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Not disposing StringFormat?
    ... Its good form to dispose of any object that you create if it is disposable. ... In the case of many GDI+ objects, StringFomat included, the System.Drawing classes are in fact nothing more than a wrapper around the unmanaged GDI+ library. ... Find great Windows Forms articles in Windows Forms Tips and Tricks ... I've always done a new StringFormat() and then set it up. ...
    (microsoft.public.dotnet.framework.drawing)
  • Re: When to Dispose of a Pen or Brush?
    ... Incidentally there is another article in the Windows Forms Tips and Tricks ... Answer those GDI+ questions with the GDI+ FAQ ... >>> I am new to DotNet and am not clear on when to dispose a pen. ...
    (microsoft.public.dotnet.framework.drawing)
  • Kudos too mick
    ... > Bitmap.GetHiconcreates the GDI object which is never released. ... > private void timer1_Tick ... >> system tray icon so I can't just paint to a control or something. ... >> every second or every minute, I dispose of the previous icon. ...
    (microsoft.public.dotnet.framework.drawing)
  • Re: Disposal of GDI Resources and GDI Limits, a puzzling question (for me at least)
    ... GDI+ resources have little or nothing whatsoever to do with GDI resources. ... Correctly calling Dispose _can be_ important because the GDI+ dll is unmanaged and therefore the wrapper classes used by .Net needs to cope with unmanaged resources. ... dispose of pens and brushes and other GDI objects lest you run out. ...
    (microsoft.public.dotnet.languages.csharp)