Solved

resource leak

Posted on 1998-12-15
4
190 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 Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
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…
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…

861 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