I tried this and failed with "class mywinsock not found" at the
createobject() line. Can we subclass an ActiveX control?

oWinsock=createobject("mywinsock")
...
define window mywinsock as MSWinsock.Winsock.1
procedure DataArrival
lparameter m.length
? m.length
endproc
endefine


--
.~. Might, Courage, Vision. In Linux We Trust.
/ v \ http://www.linux-sxs.org
/( _ )\ Linux 2.4.22-xfs
^ ^ 8:26pm up 1 day 10:53 load average: 1.00 1.00 1.00

Re: the winsock control by toylet

toylet
Tue Mar 02 06:51:23 CST 2004

sorry, typo, "define class" not "define windnow"

toylet wrote:

> I tried this and failed with "class mywinsock not found" at the
> createobject() line. Can we subclass an ActiveX control?
>
> oWinsock=createobject("mywinsock")
> ...
> define window mywinsock as MSWinsock.Winsock.1
> procedure DataArrival
> lparameter m.length
> ? m.length
> endproc
> endefine
>
>

--
.~. Might, Courage, Vision. In Linux We Trust.
/ v \ http://www.linux-sxs.org
/( _ )\ Linux 2.4.22-xfs
^ ^ 8:50pm up 1 day 11:17 load average: 1.00 0.97 0.98

Re: the winsock control by Thierry

Thierry
Tue Mar 02 07:04:40 CST 2004

> Can we subclass an ActiveX control?
Yes, through an OLE Container Class/Control
--=20
Th N
Abaque

"toylet" <toylet_at_mail.hongkong.com> a =E9crit dans le message de =
news:uCUmEIFAEHA.1844@TK2MSFTNGP11.phx.gbl...
>=20
> I tried this and failed with "class mywinsock not found" at the=20
> createobject() line. Can we subclass an ActiveX control?
>=20
> oWinsock=3Dcreateobject("mywinsock")
> ...
> define window mywinsock as MSWinsock.Winsock.1
> procedure DataArrival
> lparameter m.length
> ? m.length
> endproc
> endefine
>=20
>=20
> --=20
> .~. Might, Courage, Vision. In Linux We Trust.
> / v \ http://www.linux-sxs.org
> /( _ )\ Linux 2.4.22-xfs
> ^ ^ 8:26pm up 1 day 10:53 load average: 1.00 1.00 1.00

Re: the winsock control by toylet

toylet
Tue Mar 02 21:18:36 CST 2004

I tried and got an error "object class in invalid for this container".

owinsock=createobject("mywinsock")
define class mywinsock as olecontrol
oleclass="MSWinsock.Winsock.1"
enddefine

Thierry Nivelet wrote:
>> Can we subclass an ActiveX control?
> Yes, through an OLE Container Class/Control

--
.~. Might, Courage, Vision. In Linux We Trust.
/ v \ http://www.linux-sxs.org
/( _ )\ Linux 2.4.22-xfs
^ ^ 11:16am up 2 days 1:43 load average: 1.00 1.00 1.00

Re: the winsock control by Thierry

Thierry
Wed Mar 03 01:25:44 CST 2004

Object class is invalid for this container (Error 1744)
You have attempted to add a member object to a parent object with the =
AddObject method. It cannot be added because the member object's class =
cannot be a member of the parent's object class. For example, you cannot =
add a Grid object to a PageFrame object.

Looks like this message is due to ....

OLEClass Property
Returns the named class ID of an OLE object.=20
Read-only at design time and run time for an existing object, but can be =
set for an object when creating it.

could you try :
oContainer.addObject('owinsock', 'olecontrol', 'MSWinsock.Winsock.1')
--=20
Th N
Abaque

"toylet" <toylet_at_mail.hongkong.com> a =E9crit dans le message de =
news:efdq34MAEHA.2448@TK2MSFTNGP12.phx.gbl...
> I tried and got an error "object class in invalid for this container".
>=20
> owinsock=3Dcreateobject("mywinsock")
> define class mywinsock as olecontrol
> oleclass=3D"MSWinsock.Winsock.1"
> enddefine
>=20
> Thierry Nivelet wrote:
> >> Can we subclass an ActiveX control?
> > Yes, through an OLE Container Class/Control
>=20
> --=20
> .~. Might, Courage, Vision. In Linux We Trust.
> / v \ http://www.linux-sxs.org
> /( _ )\ Linux 2.4.22-xfs
> ^ ^ 11:16am up 2 days 1:43 load average: 1.00 1.00 1.00

Re: the winsock control by toylet

toylet
Wed Mar 03 06:54:03 CST 2004

> could you try :
> oContainer.addObject('owinsock', 'olecontrol', 'MSWinsock.Winsock.1')

If I used the addobject() method, how could I write my own
DataReceived() event for the subclassed MSwinsock? As far as I know, I
could do that only with DEFINE CLASS.

--
.~. Might, Courage, Vision. In Linux We Trust.
/ v \ http://www.linux-sxs.org
/( _ )\ Linux 2.4.22-xfs
^ ^ 8:52pm up 2 days 11:19 load average: 1.00 0.99 0.98

Re: the winsock control by Thierry

Thierry
Wed Mar 03 11:56:31 CST 2004

You could try (sorry for trial and error):

owinsock=3Dcreateobject("mywinsock", "MSWinsock.Winsock.1")

define class mywinsock as olecontrol
procedure DataReceived
<code>
enddefine

It seems that olecontrol class expects OLE class ID as first parameter =
of its init() event method
--=20
Th N
Abaque

"toylet" <toylet_at_mail.hongkong.com> a =E9crit dans le message de =
news:eydva6RAEHA.3940@TK2MSFTNGP11.phx.gbl...
> > could you try :
> > oContainer.addObject('owinsock', 'olecontrol', =
'MSWinsock.Winsock.1')
>=20
> If I used the addobject() method, how could I write my own=20
> DataReceived() event for the subclassed MSwinsock? As far as I know, I =

> could do that only with DEFINE CLASS.
>=20
> --=20
> .~. Might, Courage, Vision. In Linux We Trust.
> / v \ http://www.linux-sxs.org
> /( _ )\ Linux 2.4.22-xfs
> ^ ^ 8:52pm up 2 days 11:19 load average: 1.00 0.99 0.98

Re: the winsock control by toylet

toylet
Thu Mar 04 04:23:00 CST 2004

Didn't work neither. I could do that with form designer, but just
curious on how to subclass an activeX control by codes.

> owinsock=createobject("mywinsock", "MSWinsock.Winsock.1")
> define class mywinsock as olecontrol
> procedure DataReceived
> <code>
> enddefine
> It seems that olecontrol class expects OLE class ID as first parameter of its init() event method


--
.~. Might, Courage, Vision. In Linux We Trust.
/ v \ http://www.linux-sxs.org
/( _ )\ Linux 2.4.22-xfs
^ ^ 6:22pm up 3 days 8:49 load average: 1.00 1.00 1.00

Re: the winsock control by Thierry

Thierry
Thu Mar 04 04:31:51 CST 2004

> Didn't work neither
Which message did you get ?

One must admit activeX are more comfortable on forms...
I already had the same experience.
I don't know why and don't like it.
You may take a look at some commands like

SYS(2333) - ActiveX Dual Interface Support

--=20
Th N
Abaque

"toylet" <toylet_at_mail.hongkong.com> a =E9crit dans le message de =
news:uahWqKdAEHA.1964@TK2MSFTNGP11.phx.gbl...
> Didn't work neither. I could do that with form designer, but just=20
> curious on how to subclass an activeX control by codes.
>=20
> > owinsock=3Dcreateobject("mywinsock", "MSWinsock.Winsock.1")
> > define class mywinsock as olecontrol
> > procedure DataReceived
> > <code>
> > enddefine
> > It seems that olecontrol class expects OLE class ID as first =
parameter of its init() event method
>=20
>=20
> --=20
> .~. Might, Courage, Vision. In Linux We Trust.
> / v \ http://www.linux-sxs.org
> /( _ )\ Linux 2.4.22-xfs
> ^ ^ 6:22pm up 3 days 8:49 load average: 1.00 1.00 1.00

Re: the winsock control by Thierry

Thierry
Thu Mar 04 04:52:46 CST 2004


> One must admit activeX are more comfortable on forms...

Documentation is not clear whether a form is required or not (see below =
)
--=20
Th N
Abaque

Accessing ActiveX Controls and Objects

You can use any ActiveX control that is available on your computer. To =
use an ActiveX control, you add it to a form, then set its properties, =
write handlers for its events, or call its methods. You can add an =
ActiveX control to a form using the Form Controls toolbar or the OLE =
Container control, or by using code. For details about adding an ActiveX =
control in the Form Designer, see Adding OLE.

You can create an ActiveX control in code in much the same way you would =
create any Visual FoxPro control. However, before creating the control =
you must determine the name of the control's class library, which is =
stored in the Windows registry. If you have no other way to determine =
the class library name, use the Form Designer to create the control (as =
described in the previous section), and then get the control's OLEClass =
property.

-------------------------------------------------------------------------=
-------
ActiveX objects can be created directly with CREATEOBJECT( ), and don't =
require an instance of a form.

To create an ActiveX control in code=20

1.. Call CREATEOBJECT( ) to create a form.=20
2.. Call the new form's AddObject method to add the control, =
specifying olecontrol as the class. You must pass the control's class =
library name as the third parameter of the AddObject method.=20
For example, the following program creates a new form and adds an =
outline control to it:

oMyForm =3D CREATEOBJECT("form")
oMyForm.AddObject("oleOutline","olecontrol", "MSOutl.Outline")
-------------------------------------------------------------------------=
-------

After you've created the form and control, you can display the form by =
calling its Show method, and display the control by setting its Visible =
property to true:

oMyForm.oleOutline.Visible =3D .T.
oMyForm.ShowSome ActiveX controls aren't designed primarily to be used =
interactively by a user. For example, a timer control doesn't support =
methods for user interaction. Even then, you can still create the =
control on a form because the control will usually make available a =
default visible component, such as an icon. Frequently you will not be =
able to change or resize the icon.

If you don't want your application to display the icon for =
non-interactive controls, you can hide the control by setting the =
Visible property of its OLE container control to false, or set its Left =
property to a negative value (such as -100) that moves it off the =
visible portion of the screen. Alternatively, you can place the control =
on a form that's never made visible (that is, for which the Show method =
is never called). In all cases, you can still call the control's methods =
as if the control were visible.

"Thierry Nivelet" <info_nospam@abaqueinside.com> a =E9crit dans le =
message de news:e7d4iPdAEHA.4080@TK2MSFTNGP09.phx.gbl...
> Didn't work neither
Which message did you get ?

One must admit activeX are more comfortable on forms...
I already had the same experience.
I don't know why and don't like it.
You may take a look at some commands like

SYS(2333) - ActiveX Dual Interface Support

--=20
Th N
Abaque

"toylet" <toylet_at_mail.hongkong.com> a =E9crit dans le message de =
news:uahWqKdAEHA.1964@TK2MSFTNGP11.phx.gbl...
> Didn't work neither. I could do that with form designer, but just=20
> curious on how to subclass an activeX control by codes.
>=20
> > owinsock=3Dcreateobject("mywinsock", "MSWinsock.Winsock.1")
> > define class mywinsock as olecontrol
> > procedure DataReceived
> > <code>
> > enddefine
> > It seems that olecontrol class expects OLE class ID as first =
parameter of its init() event method
>=20
>=20
> --=20
> .~. Might, Courage, Vision. In Linux We Trust.
> / v \ http://www.linux-sxs.org
> /( _ )\ Linux 2.4.22-xfs
> ^ ^ 6:22pm up 3 days 8:49 load average: 1.00 1.00 1.00

Re: the winsock control by Marc

Marc
Thu Mar 04 08:33:02 CST 2004

Toylet,

You can add behavior to an Active-X class by using the BINDEVENTS() method.
This requires VFP8 though.


Marc


"toylet" <toylet_at_mail.hongkong.com> wrote in message
news:uCUmEIFAEHA.1844@TK2MSFTNGP11.phx.gbl...
>
> I tried this and failed with "class mywinsock not found" at the
> createobject() line. Can we subclass an ActiveX control?
>
> oWinsock=createobject("mywinsock")
> ...
> define window mywinsock as MSWinsock.Winsock.1
> procedure DataArrival
> lparameter m.length
> ? m.length
> endproc
> endefine
>
>
> --
> .~. Might, Courage, Vision. In Linux We Trust.
> / v \ http://www.linux-sxs.org
> /( _ )\ Linux 2.4.22-xfs
> ^ ^ 8:26pm up 1 day 10:53 load average: 1.00 1.00 1.00



Re: the winsock control by toylet

toylet
Thu Mar 04 08:36:44 CST 2004

The problem with createobject() is that you cannot override the built-in
methods of the class and that could only be done with DEFINE CLASS.

>> One must admit activeX are more comfortable on forms...
>
> Documentation is not clear whether a form is required or not (see below )

--
.~. Might, Courage, Vision. In Linux We Trust.
/ v \ http://www.linux-sxs.org
/( _ )\ Linux 2.4.22-xfs
^ ^ 10:34pm up 3:40 1 user 1.02 1.00

Re: the winsock control by toylet

toylet
Thu Mar 04 08:44:22 CST 2004

>> Didn't work neither
> Which message did you get ?

same message: object class in invalid for this container

--
.~. Might, Courage, Vision. In Linux We Trust.
/ v \ http://www.linux-sxs.org
/( _ )\ Linux 2.4.22-xfs
^ ^ 10:42pm up 3:48 1 user 1.00 1.00

Re: the winsock control by toylet

toylet
Thu Mar 04 08:45:51 CST 2004

I tried this and got a syntax error in the ADD OBJECT line:

owinsock=createobject("myform")
define class myform as form
add object winsock1 as "MSWinsock.Winsock.1"
procedure winsock1.DataArrival
lparameter m.length
endproc
enddefine

> Documentation is not clear whether a form is required or not (see below )

--
.~. Might, Courage, Vision. In Linux We Trust.
/ v \ http://www.linux-sxs.org
/( _ )\ Linux 2.4.22-xfs
^ ^ 10:44pm up 3:50 1 user 1.00 1.00

Re: the winsock control by toylet

toylet
Thu Mar 04 08:46:57 CST 2004

Oh, I am still using VFP 6. What cculd I do then?
Did you have experience with subclassing an activeX control
programmatically (not via form designer)?

Marc Lyon wrote:

> Toylet,
>
> You can add behavior to an Active-X class by using the BINDEVENTS() method.
> This requires VFP8 though.

--
.~. Might, Courage, Vision. In Linux We Trust.
/ v \ http://www.linux-sxs.org
/( _ )\ Linux 2.4.22-xfs
^ ^ 10:44pm up 3:50 1 user 1.00 1.00

Re: the winsock control by Rick

Rick
Thu Mar 04 13:49:09 CST 2004

toylet,
Since OLE objects like to be on "forms", this is one technique I've =
used. Note: You can add whatever methods you want to this form, and you =
just reference the control with something like:
lcMACAddress =3D oForm1.Olecontrol1.MACAddress && returned in form of =
XX-XX-XX-XX-XX-XX

I haven't tried it with WinSock, but it should work the same.

oform1 =3D CREATEOBJECT("dummyform")


*************************************
DEFINE CLASS dummyform AS form

DoCreate =3D .T.
Caption =3D "dummyform"
Name =3D "dummyform"

ADD OBJECT olecontrol1 AS MYMAC WITH ;
Top =3D 8, ;
Left =3D 8, ;
Height =3D 100, ;
Width =3D 100, ;
Name =3D "Olecontrol1"

ENDDEFINE


*************************************
DEFINE CLASS MYMAC as OLEControl

OleClass =3D 'MACAddressOCX.MACAddress'

ENDDEFINE

Rick

"toylet" <toylet_at_mail.hongkong.com> wrote in message =
news:uCUmEIFAEHA.1844@TK2MSFTNGP11.phx.gbl...
>=20
> I tried this and failed with "class mywinsock not found" at the=20
> createobject() line. Can we subclass an ActiveX control?
>=20
> oWinsock=3Dcreateobject("mywinsock")
> ...
> define window mywinsock as MSWinsock.Winsock.1
> procedure DataArrival
> lparameter m.length
> ? m.length
> endproc
> endefine
>=20
>=20
> --=20
> .~. Might, Courage, Vision. In Linux We Trust.
> / v \ http://www.linux-sxs.org
> /( _ )\ Linux 2.4.22-xfs
> ^ ^ 8:26pm up 1 day 10:53 load average: 1.00 1.00 1.00

Re: the winsock control by toylet

toylet
Fri Mar 05 02:31:44 CST 2004

That worked. Thank you.


*** mysolution.prg
owinsock=createobject("myform")
owinsock.show()

define class myform as form
add object owinsock as myole

procedure activate
this.owinsock.protocol=0
this.owinsock.remotehost="192.168.2.1"
this.owinsock.remoteport=25
_screen.print(this.owinsock.localip)
endproc
enddefine

define class myole as olecontrol
oleclass="MSWinsock.Winsock.1"
procedure DataArrival
lparameter nlength
? nlength
endproc
enddefine

> oform1 = CREATEOBJECT("dummyform")
> DEFINE CLASS dummyform AS form
> ADD OBJECT olecontrol1 AS MYMAC WITH ;
> ENDDEFINE
> DEFINE CLASS MYMAC as OLEControl
> OleClass = 'MACAddressOCX.MACAddress'
> ENDDEFINE

--
.~. Might, Courage, Vision. In Linux We Trust.
/ v \ http://www.linux-sxs.org
/( _ )\ Linux 2.4.22-xfs
^ ^ 4:30pm up 21:36 1 user 1.00 1.00