hello, programmers !!!
In the solidworks api, there are many delegate function,
I want use mouse events in vb.net, but there is no example.
how should I use the code: Dim instance As New DMouseEvents_MouseMoveNotifyEventHandler(AddressOf HandlerMethod),
and what dose it mean?
need some examples. welcome for any help !!!
Sub AddMouseHandlers(ByVal ModView As ModelView)
Dim swmouse As Mouse = ModView.GetMouse
AddHandler swmouse.MouseMoveNotify, AddressOf mousemovenotify
End Sub
Sub RemoveMouseHandlers(ByVal Modview As ModelView)
Dim swmouse As Mouse = Modview.GetMouse
RemoveHandler swmouse.MouseMoveNotify, AddressOf mousemovenotify
End Sub
Function Mousemovenotify(ByVal x As Integer, ByVal y As Integer, ByVal wparam As Integer) As Integer
'Hey the mouse moved. Do something bout it
End Function
it is important to avoid memory leaks that when you no longer need the event, that you call RemoveMouseHandlers.
i always set a local variable to the class that is watching to determine if the event handler has been attached.
if attached then remove the handler upon class dispose
DO NOT LEAVE EVENT HANDLERS OPEN IN CLASSES