unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls, nrcommbox, nrcomm, nrbarcode, nrlogfile, nrclasses;

type
  TForm1 = class(TForm)
    ListBox1: TListBox;
    Button1: TButton;
    CheckBox1: TCheckBox;
    nrDeviceBox3: TnrDeviceBox;
    Label1: TLabel;
    nrLogFile1: TnrLogFile;
    nrBarCodeScan1: TnrBarCodeScan;
    procedure nrBarCodeScan1BarCode(Sender: TObject; BarCode: String);
    procedure Button1Click(Sender: TObject);
    procedure CheckBox1Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
  private   { Private declarations }
    procedure WMDeviceChange(var Msg:TMessage); message WM_DEVICECHANGE;
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.nrBarCodeScan1BarCode(Sender: TObject; BarCode: String);
begin
  ListBox1.Items.Add(BarCode);
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  nrBarCodeScan1.ConfigDialog;
end;

procedure TForm1.CheckBox1Click(Sender: TObject);
begin
  try
    nrBarCodeScan1.Active:=CheckBox1.Checked;
  except
    CheckBox1.Checked:=nrBarCodeScan1.Active;
    raise;
  end;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  CheckBox1.Checked:=nrBarCodeScan1.Active;
end;

procedure TForm1.WMDeviceChange(var Msg: TMessage);
begin
  nrBarCodeScan1.Update;
end;

end.
