Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

resource leak

Posted on 1998-12-15
4
Medium Priority
?
208 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 800 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

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

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

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

604 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