The SSUBTMR.DLL is a modified version of HardCore Visual Basic's SUBTIMER.DLL, with a few revisions and bug patches by VB Accelerator. To download it, click here. To use it, do the following:
1) Add the following code to the general declarations section of the form you want to subclass
Implements ISubclass
Private m_emr As EMsgResponse
Private bSubclassing As Boolean
2) Also add the declarations of any messages you want to include. For example:
Public Const WM_SYSCOMMAND = &H112
3) For each message you want to subclass, you need to add a call to AttachMessage and DetachMessage. An example is given, and it uses the following syntax:
AttachMessage Form with the Implements statement, Form.hwnd you want to subclass's property, Message you want to subclass.
For example:
AttachMessage Me, hwnd, WM_OTHERWINDOWDESTROYED
So, add the following procedures.
Public Sub pAttachMessages()
m_emr = emrPreprocess
'// delete this example, and add your own
AttachMessage Me, hwnd, WM_OTHERWINDOWDESTROYED
bSubclassing = True
End Sub
Private Sub pDetachMessages()
If (bSubclassing) Then
'// delete this example, and add
your own
DetachMessage Me, hwnd,
WM_OTHERWINDOWDESTROYED
bSubclassing = False
End If
End Sub
4) Then, add the following code:
Private Property Let
ISubclass_MsgResponse(ByVal RHS As SSubTimer.EMsgResponse)
'// this proc is not really needed, but you still need to
add it!
End Property
Private Property Get ISubclass_MsgResponse() As SSubTimer.EMsgResponse
'// Tell the subclasser what to do for this message (here
we do all processing):
ISubclass_MsgResponse = emrPreprocess
End Property
Private Function ISubclass_WindowProc(ByVal hwnd As Long, ByVal iMsg As
Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Select Case iMsg
'// add Case statements for each message you wanted
subclassed:
Case WM_MESSAGE1
'// enter what you want to do
when WM_MESSAGE1 occurs
Case WM_MESSAGE2
'// enter what you want to do
when WM_MESSAGE2 occurs ...
End Select
End Function
There is also an example available for download from VB Accelerator: Download the SSubTmr project code (no DLL) (9kb)
Comments