Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Correct way to implement MSWinsock.ocx
Message
 
 
To
27/09/2001 16:36:27
General information
Forum:
Visual FoxPro
Category:
ActiveX controls in VFP
Miscellaneous
Thread ID:
00561678
Message ID:
00564786
Views:
23
>Hi;
>
>I'm trying to figure out a respectable way to use MSWinsock.ocx.
>
>I would like to subclass it as container object in such a way that all the properties and methods are exposed, and the events call corresponding methods in my container...which I could then override in subesquent subclasses.
>
>I would like to do this all non-visually, if possible.
>
>So far, I have been exploring the following possibilities:
>
>-----------------------------------------------------------
>Brute force mapping of events to the container's methods, the container's methods to the MSWinsock methods, and using Access/assign methods to handle the properties...something like this:
>
>
>DEFINE CLASS my_WinSock AS Container
>	ADD OBJECT oMSWinSock AS MSWinSock
>	
>	FUNCTION ConnectionRequest
>	LPARAMETERS (requestid)
>
>	ENDFUNC
>	
>ENDDEFINE
>
>DEFINE CLASS MSWinsock AS OLEControl
>	oleClass=[MSWinsock.Winsock.1]
>	
>	FUNCTION ConnectionRequest
>	LPARAMETERS requestid
>		This.Parent.ConnectionRequest(requestid)
>	ENDFUNC
>
>ENDDEFINE
>
>
>...which seems really tedious.
>
>
>-----------------------------------------------------------------------
>Another method I was checking out was using the IMPLEMENTS keyword in define class. However, I don't have a very good understanding of what this keyword DOES. It would seem that it is what I'm after, but I don't quite grasp it.
>
>In the TypeLib viewer, the MSWinsock control has two interfaces DMSWinsockControlEvents and IMSWinsockControl
>
>DMSWinsockControlEvents has all the events in it...but no Properties or methods. Dragging this one into a code window gets me a class definition that will work...but I can't change any properties or call methods.
>
>IMSWinsockControl has the properties and methods, but no events, and it throws an error when I try to instantiate the object.
>
>
>Any help would be greatly appreciated.
>
>Russ

Russ,
The IMPLEMENTS keyword can only be used to handle methods/events. It is used in conjunction with the new EventHandler() function to tie two objects together. Once bound, when an event occurs in the Winsock object, the corresponding event in your custom object is fired. In this case, the event could be in your container.

The EventHandler() function takes care of the behavior to pass the control's events on so you don't need the THIS.Parent... syntax.

Note: Dragging and dropping and EventHandler() in VFP 7 take the place of ExportEvents() and BindEvents() from the VFPCOM utility available since at least VFP 6.

HTH.
Larry Miller
MCSD
LWMiller3@verizon.net

Accumulate learning by study, understand what you learn by questioning. -- Mingjiao
Previous
Reply
Map
View

Click here to load this message in the networking platform