Uno de los supermercados que utiliza mi sistema POS tienen scanner/balanza de esta marca y modelo Magellan pero un modelo anterior, pero no hay diferencia en la forma de utilizarlos ya que el OPOS es un estándar.
No tengo el código que utilice pero más o menos es este:
En el Init escribe esto:
With ThisForm
.DataScale.open("DL_SC_RS232Scale") && DataScale es el nombre que le di a Activex
If .DataScale.Resultcode <> 0
=Messagebox('FALLO LA APERTURA DE LA BALANZA')
Return
EndIf
.DataScale.ClaimDevice( 0 )
.DataScale.DeviceEnabled = .T.
.DataScale.DataEventEnabled = .T.
EndWith
En el DataEvent del objeto Scale:
With Thisform
.TxtPeso = .DataScale.ScaleLiveWeight
.DataScale.DataEventEnabled = .T.
Keyboard '{ENTER}'
Endwith
Adicionalmente debes agregar un objeto Timer
Y manejar la activación y desactivación de allí.
Mas o menos asi:
With Thisform
If .DataScale.ClaimDevice( 0 ) <> 0
.DataScale.ClaimDevice( 0 )
Endif
If .DataScale.DeviceEnabled <> .T.
.DataScale.DeviceEnabled = .T.
Endif
If .DataScale.AutoDisable <> .F.
.DataScale.AutoDisable = .F.
Endif
If .DataScale.DataEventEnabled <> .T.
.DataScale.DataEventEnabled = .T.
Endif
If .DataScale.DecodeData <> .T.
.DataScale.DecodeData = .T.
Endif
Endwith
Not Importante: no olvides escribir en el Init esto _vfp.AutoYield = .F.
De la ayuda de VFP en Ingles respecto a Autoyield:
The AutoYield property should be set to false (.F.) when a form contains an ActiveX control. Setting AutoYield to false (.F.) prevents events for an ActiveX control from executing between lines of user program code. For example, if AutoYield is set to true (.T.), clicking an ActiveX control while user program code is executing may cause an event for the ActiveX control to execute, ignoring the user program code for the event, producing undesirable or unpredictable results.
The following occurs when the AutoYield property is set to false (.F.)