Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Oncomm event not firing in mscomm
Message
 
 
À
14/01/2002 13:09:32
Information générale
Forum:
Visual FoxPro
Catégorie:
Contrôles ActiveX en VFP
Divers
Thread ID:
00604408
Message ID:
00604458
Vues:
31
This message has been marked as the solution to the initial question of the thread.
Hi Tracy,

You've to download and install VFPCOM utility http://msdn.microsoft.com/vfoxpro/downloads/updates.asp.

>SNIP
>
>>Take a look at http://fox.wikis.com/wc.dll?Wiki~MsComm32~VFP.
>>You can also try to search for 'mscomm' in the message area for a recent discussion about mscomm. You cann narrow the search by looking for messages that involve Andrus Moor.
>
>Thanks, I've researched both the UT and the wiki link above. All I've found in the UT is to ensure that RThreshold = 1 or at least greater than zero. The wiki above mentioned not relying on oncomm to fire, but to bind your own oncomm. I don't understand from the example in the wiki how to do that with my code below. Any pointers? Everything works except the oncomm event does not fire. The wiki uses the following as an example of binding:
>
>
>************* FROM THE WIKI **********************************
>If the code similar to the template below is being used, you've already attached VFP code to the OnComm? event.
>
>
>DEFINE CLASS oncomm AS basecustomclass
>PROCEDURE oncomm
> *-- Some code here...
>ENDPROC
>ENDDEFINE
>
>Then put In your code:
>
>loModemComm = NEWOBJECT("MSCOMMLib.MSComm")
>loEventHandler = NEWOBJECT("OnComm", "Comm")
>loVFPCOM = NEWOBJECT("VFPCOM.ComUtil")
>loVFPCOM.BindEvents(loModemComm, loEventHandler)
>
>
>However, when I try anything close to the above, I get 'class defintion of vfpcom not found.' So I cannot continue.
>
>
>
>PUBLIC ComForm
>ComForm = CREATEOBJECT('Form')
>ComForm.AddObject("MsCom","MSCOMMCLASS")
>DO GetVer
>DO PlayMsg
>RETURN
>
>DEFINE CLASS MsCommClass AS OLEControl
>	OLECLASS = [MSCOMMLib.MSComm.1]
>	PROCEDURE WaitForResponse
>		LPARAMETERS lnDelayInSeconds
>		LOCAL lnStartTime
>		lnStartTime = SECO()
>		DO WHILE SECO() <= (lnStartTime + lnDelayInSeconds) ;
>				AND NOT SECO() < lnStartTime
>			DOEVENTS()
>		ENDDO
>	ENDPROC
>	PROCEDURE OnComm
>		*---Receive Data
>		WAIT WINDOW ALLTRIM(STR(THIS.CommEvent))
>		IF THIS.CommEvent = 2
>			IF THIS.InBufferCount>0
>				lcString = THIS.Input
>				IF !(lcString == "")
>					WAIT WINDOW "SUCCESS! Version Retrieved: "+lcString
>				ENDIF
>			ELSE
>				WAIT WINDOW "Tracy! Data Should have been Received..."
>			ENDIF
>		ENDIF
>	ENDPROC
>ENDDEFINE
>
>PROCEDURE GetVer
>	WITH ComForm.MsCom
>		.RThreshold = 1
>		.SThreshold = 1
>		.Settings = [9600,n,8,1]
>		.RTSEnable = .F.
>		.InputLen = 0
>	ENDWITH
>	m_port=1
>	ComForm.MsCom.CommPort = m_port
>	ComForm.MsCom.PortOpen = .T.
>	ComForm.MsCom.Output="~VER "+CHR(13)
>	ComForm.MsCom.WaitForResponse(2)
>	lcString=ComForm.MsCom.Input
>	WAIT WINDOW lcString NOWAIT
>	ComForm.MsCom.PortOpen = .F.
>RETURN
>
>PROCEDURE PlayMsg
>	WITH ComForm.MsCom
>		.RThreshold = 1
>		.SThreshold = 1
>		.Settings = [9600,n,8,1]
>		.RTSEnable = .F.
>		.InputLen = 0
>	ENDWITH
>	m_port=1
>	ComForm.MsCom.CommPort = m_port
>	ComForm.MsCom.PortOpen = .T.
>	ComForm.MsCom.Output = "~PLAY " + chr(13)
>	ComForm.MsCom.Output = "M " + chr(13)
>	ComForm.MsCom.PortOpen = .F.
>RETURN
>
--sb--
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform