GDI leak
- From: Johan Stäck <johan@xxxxxxxx>
- Date: Tue, 09 Jan 2007 10:14:38 +0100
Hello,
For quite some time, I have been using a function that I found somewhere on the 'net.
It looks like this:
Public Function CreateMyFont(nSize As Integer, nDegrees As Long) As Long
' 'Create a specified font
CreateMyFont = CreateFont(-MulDiv(nSize, GetDeviceCaps(GetDC(0), LOGPIXELSY), 72), 0, nDegrees * 10, 0, FW_NORMAL, False, False, False, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, PROOF_QUALITY, DEFAULT_PITCH, "MS Sans Serif")
End Function
Now, I understand that it causes GDI leaks.
Occasional use wasn't so harmful, but I started using it in a frequently called paint routine, and then things got nasty.
As I understand it, one must release the DC after calling GetDC.
But what is the correct hWnd parameter for ReleaseDC in this case?
(After calling GetDC with 0 as parameter...)
Tia,
Johan Stäck
Skellefteå
Sweden
.
- Follow-Ups:
- Re: GDI leak
- From: Thorsten Albers
- Re: GDI leak
- Prev by Date: Re: AntiAlias Line Optimization
- Next by Date: Re: GDI leak
- Previous by thread: AntiAlias Line Optimization
- Next by thread: Re: GDI leak
- Index(es):