Note that there are some explanatory texts on larger screens.

plurals
  1. POSetWindowSubclass is leaking user objects
    primarykey
    data
    text
    <p>I'm using <a href="http://www.oocities.org/the_real_sz/misc/bear_.htm" rel="nofollow noreferrer">Bear</a> to inspect user objects and the WindowProc count is never decreasing upon RemoveWindowSubclass. So does the total in USER which is the User Objects in Task Manager.</p> <p>I read Raymond's <a href="http://blogs.msdn.com/oldnewthing/archive/2003/11/11/55653.aspx" rel="nofollow noreferrer">Safer subclassing</a> comment on removing subclassing before destroying the window but my test is done w/o destroying it at all.</p> <p>The same subclassing API is used internally by the comctl's tooltip class for TTF_SUBCLASS'ed tools, so more leaks occur if you are using non-cooperative tooltips.</p> <p>Here is the VB6 code</p> <pre><code>'--- Form1.frm ' Option Explicit Private Declare Function SetWindowSubclass Lib "comctl32" (ByVal hwnd As Long, ByVal pfnSubclass As Long, ByVal uIdSubclass As Long, ByVal dwRefData As Long) As Long Private Declare Function DefSubclassProc Lib "comctl32" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long Private Declare Function RemoveWindowSubclass Lib "comctl32" (ByVal hwnd As Long, ByVal pfnSubclass As Long, ByVal uIdSubclass As Long) As Long Private Sub Command1_Click() Call SetWindowSubclass(hwnd, AddressOf RedirectTabPaneEditWndProc, 10, ObjPtr(Me)) End Sub Private Sub Command2_Click() Call RemoveWindowSubclass(hwnd, AddressOf RedirectTabPaneEditWndProc, 10) End Sub Friend Function frWndProc(ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long frWndProc = DefSubclassProc(hwnd, wMsg, wParam, lParam) End Function '--- Module1.bas ' Option Explicit Public Function RedirectTabPaneEditWndProc( _ ByVal hwnd As Long, _ ByVal wMsg As Long, _ ByVal wParam As Long, _ ByVal lParam As Long, _ ByVal uIdSubclass As Long, _ ByVal This As Form1) As Long #If uIdSubclass Then '--- touch args #End If RedirectTabPaneEditWndProc = This.frWndProc(hwnd, wMsg, wParam, lParam) End Function </code></pre> <p>If any can leave a comment what's going on and how to resolve the leaks will be great.</p> <p>Anyone else be warned if you're doing intensive subclassing with SetWindowSubclass API.</p> <p>cheers,<br> &lt;/wqw&gt;</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload