Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Adding methods to a class object
Message
 
To
15/08/2007 19:19:32
Jay Johengen
Altamahaw-Ossipee, North Carolina, United States
General information
Forum:
Visual FoxPro
Category:
Classes - VCX
Environment versions
Visual FoxPro:
VFP 9 SP1
Miscellaneous
Thread ID:
01248400
Message ID:
01248411
Views:
29
Jay,

I never used the Winsock control other than for very simple tasks where I droped it on a form, but I think that in your case you should implement it's interface to get the events, something like the following (I am not 100% sure if the following works, it is just what I would try first)
DEFINE CLASS EMPS_Out_Class AS Session OLEPUBLIC
	IMPLEMENTS DMSWinsockControlEvents IN "c:\windows\system32\mswinsck.ocx"

	PROCEDURE DMSWinsockControlEvents_Error(Number AS INTEGER, Description AS STRING, Scode AS Number, Source AS STRING, HelpFile AS STRING, HelpContext AS Number, CancelDisplay AS LOGICAL) AS VOID;
 				HELPSTRING "Error occurred"
	* add user code here
	ENDPROC

	PROCEDURE DMSWinsockControlEvents_DataArrival(bytesTotal AS Number) AS VOID;
 				HELPSTRING "Occurs when data has been received from the remote computer"

		strData = SPACE(256)  && Define string to pass to GetData

		This.oSock.Object.GetData(@strData)
		ThisForm.txtOutput.Value = strData

		* Testing code to parse HL7 billing data from Medinotes Client to EM tables
		Send_HL7_Demographic_Data(strData)

		* Convert_HL7_Billing_Data(FILETOSTR("c:\HL7_IN\HL7BB.tmp"))

		* STRTOFILE(strData,"c:\HL7_IN\HL7_Data_From_Service.txt",.T.)
	ENDPROC

	PROCEDURE DMSWinsockControlEvents_Connect() AS VOID;
 				HELPSTRING "Occurs connect operation is completed"
	* add user code here
	ENDPROC

	PROCEDURE DMSWinsockControlEvents_ConnectionRequest(requestID AS Number) AS VOID;
 				HELPSTRING "Occurs when a remote client is attempting to connect"
		#DEFINE sckClosed 0

		If This.Object.State <> sckClosed 
			This.oSock.Object.Close
		ENDif

		*!* Accept the request with the requestID 
		*!* parameter.
		This.oSock.Object.Accept(requestID)
	ENDPROC

	PROCEDURE DMSWinsockControlEvents_Close() AS VOID;
 				HELPSTRING "Occurs when the connection has been closed"
	* add user code here
	ENDPROC

	PROCEDURE DMSWinsockControlEvents_SendProgress(bytesSent AS Number, bytesRemaining AS Number) AS VOID;
 				HELPSTRING "Occurs during process of sending data"
	* add user code here
	ENDPROC

	PROCEDURE DMSWinsockControlEvents_SendComplete() AS VOID;
 				HELPSTRING "Occurs after a send operation has completed"
	* add user code here
	ENDPROC

	oSock = NULL

	PROCEDURE INIT

		THIS.oSock = CREATEOBJECT("MSWinsock.Winsock.1")
		Eventhandler(this.oSock, this)

	ENDPROC

enddefine
[Update]
I noticed you have references to thisform and to some procedures, while the latter might work, i will add them as methods of the class instead
"The five senses obstruct or deform the apprehension of reality."
Jorge L. Borges?

"Premature optimization is the root of all evil in programming."
Donald Knuth, repeating C. A. R. Hoare

"To die for a religion is easier than to live it absolutely"
Jorge L. Borges
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform