It is many years since I did anything with FoxPro, but I have a legacy system that needs work. Okay, I can call a COM-based application such as MapPoint or Excel from FoxPro. I've done that before. However, how do I pass a function or object method as an event callback? Is it even possible? (I can't find anything online or the FoxPro books I've managed to track down)
The following is a VB6 example of what I mean, taken from the MapPoint documentation. As it happens OnConnection()
is itself a callback; but the call to moaApp.AddCommand()
passes a reference to a callback function ( SayHello()
) to MapPoint (moApp
), as a menu callback.
Not that it matters for the question, but I'm probably going to need to trap the Save, Quit, and Menu callback events.
Dim moaApp As MapPoint.Application
Public Sub SayHello()
MsgBox "Hello"
End Sub
Private Sub AddinInstance_OnConnection(ByVal Application As Object, ByVal ConnectMode As
AddInDesignerObjects.ext_ConnectMode, ByVal AddInInst As Object, custom() As Variant)
On Error GoTo error_handler
Set moaApp = Application
'Add this command to the menu (HOW DO I DO THIS IN FOXPRO?)
moaApp.AddCommand "Saying Hello", "SayHello", Me
Exit Sub
error_handler:
MsgBox Err.Description
End Sub