You can only write code into the OnData event, if you create a class based on OnlineWeightDLL.pack, via
CREATE CLASS myPack Of myvcx.vcx As Olecontrol
Then choosing OnlineWeightDLL.pack
If OnlineWeightDLL.pack is not in that list, it's not an OCX but just a COM Server class.
Then what you can do is create an eventhandler class implementing the/an interface of the OnlineWeightDLL.pack with it's events.
open the object browser for that, click on the upper left toolbar icon to open a dialo for choosing COM libraries. In the "Com libraries" tab OnlineWeightDLL.pack might be listed, easier than browsing that list is to use the browse button and navigate to your DLL file.
Now in the main object browser window open the main node, it's interfaces subnote to find the Ipackevents interface (most probably, could also be named different).
Now create a new prg and drag the interface node into the program editor.
This will create code defining an event handler class:
Code:
DEFINE CLASS PackEventhandler AS session OLEPUBLIC
IMPLEMENTS Ipackevents IN "pack.dll"
PROCEDURE Ipackevents_OnData(parameters) AS ...;
HELPSTRING "Fired when database arrives."
* add user code here
ENDPROC
..
ENDDEFINE
Here you can add your code for the OnData event. Don't delete any procedure just because you only want to add code to the ondata events. It's important all events are implemented, this is kind of a contract with much "fineprint", even if you only want to use the OnData event.
But sorry, we're not yet finished.
To put this together you need now to use CREATEOBJECT() two times, once as you already know, and once more for the eventhandler object:
Code:
loPack=CREATEOBJECT('OnlineWeightDLL.pack')
SET PROCEDURE TO yournew.prg ADDITIVE
loPackEvents=CREATEOBJECT('PackEventhandler')
* finally bind the one to the other
Eventhandler(loPack,loPackEvents)
At the point of callin Eventhandler, the "contract" I mentioned above is made between the loPack object and the loPackEvents eventhandler and all the events of oPack are connected with the methods (procedures within the DEFINE CLASS prg) of the loPackEvents object.
More in general is to be found in the help chapter on DEFINE CLASS in the subtopic explaining the IMPLEMENTS clause. and the topics referenced in "See Also". If you want to know more and dive in deeper, here's that starting point:
It's complicated, as VFP itself can only implement events of COM classes. In VFP itsef you can't create events of classes, only methods. We live by the events we are given by the base classes.
Bye, Olaf.