Re: Fixing Window Region Memory Leak
- From: "wxforecaster" <wxforecaster@xxxxxxxxx>
- Date: Thu, 21 Dec 2006 15:00:53 -0600
Nevermind. Total brain fart.
Just cleaning up the TmpRegn in the scope of the for loop fixed it up. Wow I
need some serious sleep.
"wxforecaster" <wxforecaster@xxxxxxxxx> wrote in message
news:edXJH$TJHHA.3936@xxxxxxxxxxxxxxxxxxxxxxx
The code below is used to create a transparent window region around some
controls on a form -- it works just fine.
Everytime I execute the code below however, I'm eating some serious GDI
resources due to an apparent memory leak. My guess is that it's because
I'm creating a number of separate instances of TmpRegn through repeated
use of CreateRectRgn in the for loop, and my cleanup code only removes the
most recent one???
What's a better way to handle this? Make an array of TmpRegn??
Evan
Dim Regn As Long
Dim TmpRegn As Long
Dim TmpControl As Control
'makes everything invisible
Regn = CreateRectRgn(0, 0, 0, 0)
'A loop to check every control in the form
For Each TmpControl In Me
'Create a rectangular region with its parameters
If TmpControl.Visible = True And TmpControl.Width <> 0 Then
TmpRegn = CreateRectRgn(TmpControl.Left, TmpControl.Top,
TmpControl.Left + TmpControl.Width, TmpControl.Top + TmpControl.Height)
'Combines the regions
CombineRgn Regn, Regn, TmpRegn, RGN_XOR
End If
Next TmpControl
'Make the regions
SetWindowRgn Me.hWnd, Regn, True
DeleteObject (Regn)
DeleteObject (TmpRegn)
.
- References:
- Fixing Window Region Memory Leak
- From: wxforecaster
- Fixing Window Region Memory Leak
- Prev by Date: Fixing Window Region Memory Leak
- Next by Date: Shape Control
- Previous by thread: Fixing Window Region Memory Leak
- Next by thread: Shape Control
- Index(es):
Relevant Pages
|