[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: MFC question: is it really necessary to call DeleteObject?

From: Hans-Werner Dietz <hans-werner.dietz_at_dbt.de>
Date: 2007-10-10 08:22:15 CEST

Andreas Nicolai schrieb:
> Hi there,
>
> after creating a font
>
> CFont myFont;
> myFont.CreatePointFont(...);
>
> and setting a font to the device context with
>
> CFont * oldFont = dc.SelectObject(&myFont);
>
> and restoring it with
>
> dc.SelectObject(oldFont);
>
> do I really have to delete the object with
>
> myFont.DeleteObject();
>
> as it is written in the MFC docs?
>
> If that is really necessary it has been forgotten many times in the
> MyGraph.cpp.
>
> Bye,
> Andreas
>
If you dont delete it, the Fonts stay in memory and you have memory
leaks. Easiest way for never forget it is using a small C++ class
wrapper where the destructor automatically deletes the font after
selecting the old font.
best regards
Hans-Werner

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tortoisesvn.tigris.org
For additional commands, e-mail: dev-help@tortoisesvn.tigris.org
Received on Wed Oct 10 08:45:30 2007

This is an archived mail posted to the TortoiseSVN Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.