Solved

resource leak

Posted on 1998-12-15
4
198 Views
Last Modified: 2010-05-03
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
0
Comment
Question by:janeausten
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 

Author Comment

by:janeausten
ID: 1450378
Edited text of question
0
 
LVL 8

Expert Comment

by:MikeP090797
ID: 1450379
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
0
 

Author Comment

by:janeausten
ID: 1450380
Yep, mike, i think that's it...

repost your comment and get your points

and..

THANKS!
0
 
LVL 8

Accepted Solution

by:
MikeP090797 earned 200 total points
ID: 1450381
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
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

687 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question