Appendix:  WithEvents

To handle the events raised by an event source (such as a SubClasser object), declare a variable using the keyword WithEvents.

Private WithEvents objmSubclasser As SubClasser

This will put objmSubclasser in the left drop-down list of your code window, and events raised by objmSubclasser can be selected from the right drop-down list, just like a visual control placed on the form's designer window.

For objmSubclasser to actually raise any events though, it must be explicity created at run-time.

Eg:

Private Sub Form_Load()
    Set objmSubClasser = SubClassWindow(hWnd)
End Sub

 

Home

Copyright and Disclaimer