Firstly, it should be noted that I am using VB5 SP0, and it is not possible
at all to upgrade to SP3 or any higher version of VB.

As part of a requirement from 'on high', I've been told to dump all ActiveX
controls that we are currently using and to replace them with UserControls.
Fair enough, except that each ActiveX control has its own code modules, so
I've tried to consolidate these modules into a single code module. The
UserControls are subclassed, so I have a common WndProc in the code module
that forwards to each UserControl's friend WndProc function.

However, VB chokes while compiling or running the program on the indicated
line, and if I attempt to debug and resume execution the IDE GPFs.

Public Function WndProc (ByVal hWnd As Long, ByVal uMsg As Long, ByVal
wParam As Long, ByVal lParam As Long) As Long
Dim pObj As Object, lpPrevWndProc As Long
Set pObj = PtrToCtl(GetProp(hWnd, "ControlPtr"))
lpPrevWndProc = GetProp(hWnd, "OldWndProc")
If Not (pObj Is Nothing) Then
'// VB throws the error on the next line.
WndProc = pObj.WndProc(hWnd, uMsg, wParam, lParam)
If lpPrevWndProc <> 0 Then
WndProc = CallWindowProc(lpPrevWndProc, hWnd, uMsg, wParam, lParam)
WndProc = DefWindowProc(hWnd, uMsg, wParam, lParam)
End If
End If
End Function

Public Function PtrToCtl (ByVal ptr As Long) As Object
If ptr = 0 Then
Set PtrToCtl = Nothing
Exit Function
End If
Dim oCtl As Object
CopyMemory oCtl, ptr, 4
Set PtrToCtl = oCtl
CopyMemory oCtl, 0&, 4
End Function

In the UserControl's source code, however, there *is* a WndProc function,
and it doesn't matter what (if anything) is inside the code. Making it a
Public function results in an error message similar to the following:

"Method WndProc of _TreeView failed."

Friend Function WndProc (ByVal hWnd As Long, ByVal uMsg As Long, ByVal
wParam As Long, ByVal lParam As Long) As Long
'// ...
End Function

My intention is actually to write a generic WndProc forwarder for each
UserControl. I have tried getting the UserControls to implement a callback
interface, but that leads to the same issue.

Additionally, I am using some vtable replacement code for the
IOleInPlaceActiveObject interface, but the error and subsequent crash still
occurs even if that code is commented out.

Any help on this matter will be greatly appreciated.