Solved

resource leak

Posted on 1998-12-15
4
183 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
  • 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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

762 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now