//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop

#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma link "nrclasses"
#pragma link "nrcomm"
#pragma link "nrcommbox"
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
        : TForm(Owner)
{
}
//---------------------------------------------------------------------------

void __fastcall TForm1::AddInfo(AnsiString sCapt, AnsiString sVal)
{
        TListItem *Itm;
        if(sVal.Trim() == "") return;
        Itm = lvProperties->Items->Add();
        Itm->Caption = sCapt;
        Itm->SubItems->Add(sVal);
}

void __fastcall TForm1::AddDeviceInfo(TnrDevice * dev)
{
  AddInfo("DOS", dev->NameDeviceDos );
  AddInfo("Friendly Name", dev->NameFriendly);
  AddInfo("Description", dev->Description);
  AddInfo("PDO", dev->NamePDO);
  AddInfo("Service", dev->Service);
  AddInfo("Manufacturer", dev->Manufacturer);
}

void __fastcall TForm1::nrDeviceBox1Change(TObject *Sender)
{
  lvProperties->Items->Clear();
  AddDeviceInfo(nrComm1->Device[nrComm1->DeviceIndex]);
}

//---------------------------------------------------------------------------

int __fastcall TForm1::WMDeviceChange(TMessage &Msg)
{
  int i = nrComm1->DeviceIndex;
  nrComm1->WMDeviceChange(Msg);
  nrComm1->DeviceIndex = i;
  nrDeviceBox1Change(this);
  return 0;
}

//---------------------------------------------------------------------------
