Ver Mensaje Individual
  #14  
Antiguo 14-06-2011
Avatar de newtron
[newtron] newtron is offline
Membrillo Premium
 
Registrado: abr 2007
Ubicación: Motril, Granada
Posts: 3.474
Reputación: 21
newtron Va camino a la fama
Hola.

Aquí te envío un ejemplo de la captura del evento "Receivedata" del componente por si te sirve.

Código Delphi [-]

procedure TFormularioVentasTactil.PesoReceiveData(Sender: TObject;
  DataPtr: Pointer; DataSize: Cardinal);
var
  iLastLine, i: integer;
  s, ss: string;
begin
//
  //Convertimos los datos recibidos en una cadena
  s := StringOfChar(' ', DataSize);
  Move(DataPtr^, pchar(s)^, DataSize);

  //Salimos si recibimos el caracter nulo
  while Pos(#0, s) > 0 do
    Delete(s, pos( #0, s ), 1);

  //Comprobamos que la cadena recibida no este vacia o que el valor que esta recibiendo sea '0000000'(que no hay nada en el peso)
  if (s = '') then begin
    Exit;
  end;
  if (Pos('0000000',s) = 1) and (Not Pesamos) then exit;

  if Pos('0000000',s)=1 then
    Pesamos:=False
  else
    Pesamos:=True;

  // Remove line feeds
  i := pos( #10, s );
  while i <> 0 do begin
    delete( s, i, 1 );
    i := pos( #10, s );
  end;

  // Don't redraw the rich edit control until we finished updating it
  //IncomingRichEdit.Lines.BeginUpdate;
  // Get last line index
  iLastLine := NTMemo1.Lines.Count-1;
  // If the rich edit is empty...
  if iLastLine = -1 then begin
    // Remove line feeds from the string
    i := pos( #10, s );
    while i <> 0 do begin
      delete( s, i, 1 );
      i := pos( #10, s );
    end;
    // Remove carriage returns from the string (break lines)
    i := pos( #13, s );
    while i <> 0 do begin
      ss := copy( s, 1, i-1 );
      delete( s, 1, i );
      NTMemo1.Lines.Append( ss );
      i := pos( #13, s );
    end;
    NTMemo1.Lines.Append( s );

  end else begin
    // String to add is : last line added + new one
    s := NTMemo1.Lines[iLastLine] + s;
    // Remove carriage returns (break lines)
    i := pos( #13, s );
    while i <> 0 do begin
      ss := copy( s, 1, i-1 );
      delete( s, 1, i );
      if iLastLine <> -1 then begin
        NTMemo1.Lines[iLastLine] := ss;
        iLastLine := -1;
      end else begin
        //introducimos cantidad en el grid de ventas
        NTMemo1.Lines.Append( ss );
      end;
      if ss<>'0000000' then begin
        MiVenta.CambiaModoEdit(tEntradaDatos);
        NtEditTotal.TomaValor(ss);
      end else begin
        Miventa.CambiaModoEdit(tPresentaTotal);
      end;
      i := pos( #13, s );
    end;

    if iLastLine <> -1 then
      NTMemo1.Lines[iLastLine] := s
    else
      NTMemo1.Lines.Append( s );
  end;

end;

Saludos
Responder Con Cita