'Create an ActiveX DLL project named SmartSubClassLib
'Put the following code in the standard module. The module name is mSmartSubClass.
'----------------------------------------------------
'Module mSmartSubClass
'
'Version... 1.0
'Date... 24 then l 2001
'
'Copyright (C) 2001 Android +pons (andres@vbsmart.com)
'----------------------------------------------------
'Api declarations:
Option Explicit
Public Const SSC_OLDPROC = "SSC_OLDPROC"
Public Const SSC_OBJADDR = "SSC_OBJADDR"
Private Declare Function GetProp Lib "user32" Alias "GetPropA "(_
ByVal hWnd As Long ,_
ByVal lpString As String) As Long
Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory "(_
Destination As Any ,_
Source As Any ,_
ByVal Length As Long)
'
'Function StartSubclassWindowProc ()
'
'This is the first windowproc that contains es messages
'For all subclassed windows.
'The aim of this function is to just collect The message
'And deliver it to the right SmartSubClass instance.
'
Public Function SmartSubClassWindowProc (_
ByVal hWnd As Long ,_
ByVal uMsg As Long ,_
ByVal wParam As Long ,_
ByVal lParam As Long) As Long
Dim lRet As Long
Dim oSmartSubClass As SmartSubClass
'Get the memory address of the class instance...
LRet = GetProp (hWnd, SSC_OBJADDR)
If lRet <> 0 Then
'Osmartsubclass will point to the class instance
'Without incrementing the class reference counter...
CopyMemory oSmartSubClass, lRet, 4
'Send the message to the class instance...
SmartSubClassWindowProc = oSmartSubClass. WindowProc (hWnd ,_
UMsg, wParam, lParam)