Link to home
Start Free TrialLog in
Avatar of janeausten
janeausten

asked on

resource leak

hi everyone

smart check uncovered a resource leak error in my creation
of logical fonts.  before i call createfont, i have this:

if fonttouse<>0 then
      rc = deleteobject(fonttouse)
      fonttouse = 0
endif

i tried tracing the value of fonttouse, after the deleteobject line
the value of fonttouse still remained, that's why i added the
"fonttouse = 0" line.  

does anyone know how deleteobject really works?  i don't know
why the value of fonttouse remains after that function is called.  
by the way, i got that part from dan appleman's winapi book,
chapter 11 - fonts.

any help welcome
thanks in advance

merry christmas to all
Avatar of janeausten
janeausten

ASKER

Edited text of question
The value shouldn't change, it represents the handle of the object, not the actual object. For instance, if the variable contains 3, you could simply pass 3 instead.
The font is not being freed probobly because it is still selected into the device context. You must select a different font (You can use GetStockObject for that), and only after that use DeleteObject.

If this was the case, please reply, and I will post the comment as an asnwer
Yep, mike, i think that's it...

repost your comment and get your points

and..

THANKS!
ASKER CERTIFIED SOLUTION
Avatar of MikeP090797
MikeP090797

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial