>I have been using a MSWinsock control on a form in an application and now wish to using it in a program and want to put code in the dataarrival event. I have tried the following but it does not work I get an error that says 'Object class is invalid for this container.'
>
That message usually indicates that you tried to add an OleCOntrol somewhere that didn't like it (like to _screen).
In order to respond to events, you're going to have to create a custom class that will provide VFP code to hook into the Winsock control's events, and bind the custom class to the Winsock ActiveX control (
NOT the OleControl that sits on the form!) using VFPCOM, an add-on that, among other things, can examine the available events for an ActiveX control and produce a template .PRG that can be used as a starting point for writing the custom class, and bind the events of an ActiveX control to correspondingly-named methods of an instance of the custom class.
>Osock = createobject("PrgSocket")
>Osock.LocalPort = 5001
>Osock.Protocol = 1
>
>Define Class PrgSocket as OleControl
> Oleclass = "MSWinsock.Winsock"
> function DataArrival
> lparameter bytestotal
> wait window allt(str(bytestotal)) nowait
> return
> endfunc
>enddefine
>
>This however does work but I don't know how to add code to the dataarrival event.
>
>Osock = createobject("MSWinsock.Winsock")
>Osock.Protocol = 1
>Osock.LocalPort = 5001
>
>Any ideas would be greatly appreciated.
>Thanks for the help!
>David