[Lazarus] Fw: Re: One last ask for help

Sven Barth pascaldragon at googlemail.com
Thu Mar 21 16:32:09 CET 2013


Am 21.03.2013 16:26, schrieb Antonio Fortuny:
> procedure TMyForm.FormKeyPress(Sender: TObject; var Key: char);
> begin
>   case Ord(Key) of
>     {$IFDEF WIN32}
>     Ord('>'),  // this helps to simulate on Win32
>     {$ENDIF}
>     Ord(#03): begin   // aka EOT
>       Key := #0;
>       try
>         if Scann.Buffer = EmptyStr then
>           Exit;
>         codebarre := scann.buffer;
>         ...
>         ... do whatever has to be done with the scannes barcode
>         ...
>       finally
>         Scann.Reset;
>         Scann.Reading := False;
>       end
>     end;
>     {$IFDEF WIN32}
>     Ord('<'),   // this helps to simulate on Win32
>     {$ENDIF}
>     Ord(#02): begin   // aka STX
>       Scann.Reset;
>       Key := #0;   // ignore key
>       Scann.Reading := True;
>     end
>     else begin
>       Scann.Buffer := Scann.Buffer + Key;
>       Key := #0;   // ignore key
>     end
>   end
>
> end;
>
Out of curiosity: why do you use "Ord"? You can achieve the same by just 
using the chars:

=== code begin ===
   case Key of
     '>',
     #03: begin
       //...
     end;
     '<',
     #02: begin
       //...
     end;
     else begin
       //...
     end;
   end;
=== code end ===

Regards,
Sven




More information about the Lazarus mailing list