>I have a COM class library in VisFox 6 that I would like to use in VB and have the class raise an event that can be picked up in VB6.
>
>I'm pretty sure it's possible; but haven't a clue on the syntax to get started.
First of all, make sure that you really need to raise events within VFP library. IMO the only reason for it is passing events from MS Comm or Winsock controls:
1. VFP COM library cannot have user-generated events (from keyboard or mouse).
2. You can use timer and trap timer events directly in VB code.
3. If you plan to generate events within methods of VFP objects, then you can return an appropriate value from this method instead and interprete it in VB code.
To implement client notification in VFP class you can use callback interfaces instead of event mechanism. Add property to VFP class to store a reference to VB object, which you will use for notification.
In VFP:
DEFINE CLASS MyClass AS SESSION OLEPUBLIC
EventObject = Null
....
This.EventObject.SomeMethod()
....
ENDDEFINE
In VB:
Dim oFox As New MyServer.MyClass
Sub Initialize()
oFox.EventObject = Me
End Sub
Sub Terminate()
oFox.EventObject = Nothing
End Sub
Sub SomeMethod()
' Event handler
MsgBox "Hello from VFP!"
End Sub