Unanswered: Passing Argument To Public Event Handler
How to pass a default argument to the public event handler?
Event handler for mouse move will have Button, Shift, X, and Y... How to get this value if the event handler is on the module. I want to assign this handler programmatically from the vb code, therefore I use something like: ctlControl.OnMouseMove = "=myMoveHandler()"
If I define the args of myMoveHandler as follows
(Button As Integer, Shift As Integer, X As Single, Y As Single),
how can I pass these values from the OnMouseMove property of every controls in my form?
You could define a Class Module clsMoveHandler which does this for you:
Private WithEvents mctlControl As Control
Public Property Set Control(ctlControl As Control)
Set mctlControl = ctlControl
mctlControl.OnMouseMove = "[Event Procedure]"
Private Sub ctlControl_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
'Your Event Handler Here
Debug.Print ctlControl.Name & ".clsMoveHandler.MouseMove"
You can then specify this handler for each control you want to use it for:
Private mhndlrControl1 As clsMoveHandler
Private Sub Form_Open()
Set mhndlrControl1 = New clsMoveHandler
Set mhndlrControl1.Control = ctlControl1
When the mouse moves over ctlControl1 your event handler is called.
If you want to do this for multiple controls you'll probably want to define an array or Collection of clsMoveHandler and add each Control to it one at a time...