Re: CreateFontIndirect: will this cause a memory leak?
- From: Mark Raishbrook <MarkRaishbrook@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Mon, 24 Jul 2006 10:16:02 -0700
Many thanks, Thorsten. That's cleared things up for me.
(Don't worry about the VidDC thing -- it was a copy and paste typo)
"Thorsten Albers" wrote:
Mark Raishbrook <MarkRaishbrook@xxxxxxxxxxxxxxxxxxxxxxxxx> schrieb im.
Beitrag <39504D1F-041E-4776-B333-41D51F05DFAC@xxxxxxxxxxxxx>...
Dim hFont As Long, oldFont As Long
hFont = CreateFontIndirect(lF)
oldFont = SelectObject(DC, hFont)
Call TextOut(DC, iXPos, iYPos, sz, Len(sz))
lF.lfQuality = CLEARTYPE_QUALITY
hFont = CreateFontIndirect(lF)
oldFont = SelectObject(VidDC, hFont)
Call TextOut(DC, iXPos + iOffsetX, iYPos + iOffsetY, sz, Len(sz))
Call SelectObject(DC, oldFont)
Call DeleteObject(hFont)
hFont = CreateFontIndirect(lF)
If hFont Then
oldFont = SelectObject(DC, hFont)
Call TextOut(DC, iXPos, iYPos, sz, Len(sz))
lF.lfQuality = CLEARTYPE_QUALITY
hFontNew = CreateFontIndirect(lF)
If HFontNew Then
if SelectObject(VidDC, hFontNew) Then
' Should be 'DC' and not 'VidDC'???
Call DeleteObject(hFont)
hFont = hFontNew
hFontNew = 0
Call TextOut(DC, iXPos + iOffsetX, iYPos + iOffsetY, sz, Len(sz))
End If
End If
Call SelectObject(DC, oldFont)
If hFontNew Then DeleteObject(hFontNew)
Call DeleteObject(hFont)
End If
- CreateFontIndirect() doesn't know that previous a font has already been
created from the LOGFONT data; therefore you have to delete any font
created with CreateFontIndirect() explicitely
- A font can be deleted only after it has been deselected from any DC to
which it has been selected before
--
----------------------------------------------------------------------
THORSTEN ALBERS Universität Freiburg
albers@
uni-freiburg.de
----------------------------------------------------------------------
- References:
- Re: CreateFontIndirect: will this cause a memory leak?
- From: Thorsten Albers
- Re: CreateFontIndirect: will this cause a memory leak?
- Prev by Date: Re: CreateFontIndirect: will this cause a memory leak?
- Next by Date: Re: CreateFontIndirect: will this cause a memory leak?
- Previous by thread: Re: CreateFontIndirect: will this cause a memory leak?
- Next by thread: Re: CreateFontIndirect: will this cause a memory leak?
- Index(es):
Relevant Pages
|