Fixing Window Region Memory Leak
- From: "wxforecaster" <wxforecaster@xxxxxxxxx>
- Date: Thu, 21 Dec 2006 14:37:09 -0600
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)
.
- Follow-Ups:
- Re: Fixing Window Region Memory Leak
- From: wxforecaster
- Re: Fixing Window Region Memory Leak
- Prev by Date: How to image processing on frames of any type of movie (vb6)
- Next by Date: Re: Fixing Window Region Memory Leak
- Previous by thread: How to image processing on frames of any type of movie (vb6)
- Next by thread: Re: Fixing Window Region Memory Leak
- Index(es):
Relevant Pages
|