I'm using Bear 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.
I read Raymond's Safer subclassing comment on removing subclassing before destroying the window but my test is done w/o destroying it at all.
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.
Here is the VB6 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
If any can leave a comment what's going on and how to resolve the leaks will be great.
Anyone else be warned if you're doing intensive subclassing with SetWindowSubclass API.
cheers,
</wqw>