Author Topic: How to enumerate without TnrDeviceBox ?  (Read 2180 times)

ChrBlack

  • Newbie
  • *
  • Posts: 3
    • View Profile
How to enumerate without TnrDeviceBox ?
« on: October 28, 2009, 03:14:18 pm »
Hello!

I have a problem with handling HID devices in Delphi 2007. I've noticed that i can't use nrHID without nrDeviceBox.
For examlple if i put nrHid1 object into the form and call nrHid1.DeviceCount then it returns zero.
But if i put nrDeviceBox1 object and nrHid1 and set nrDeviceBox1.nrComm property to nrHid1 then nrHid1.DeviceCount returns the valid value.

My problem is i don't want to use TnrDeviceBox because i will never use it but it seems i can't enumerate devices without it. Another problem that i need to write a class (in a simple unit.pas) for handling several devices and i want to create objects dinamically in the constructor of the class. The problem is nrDeviceBox derived from ComboBox and it needs a parent window (i get an error message like "...Control has no parent window" error).

Some code from the constructor of my class (nrHid1 and nrDeviceBox1 are private variables of the class)
Code: [Select]
nrHid1:=TnrHid.Create(nil);
nrDeviceBox1:=TnrDeviceBox.Create(nil);
nrDeviceBox1.nrComm:=nrHid1;

The error what i described above pops up at the third line.


« Last Edit: October 28, 2009, 03:25:04 pm by ChrBlack »

Roman Novgorodov

  • Engineer
  • Administrator
  • Hero Member
  • *****
  • Posts: 994
  • we will win
    • View Profile
    • Forums.nrCommLib.Com
Re: How to enumerate without TnrDeviceBox ?
« Reply #1 on: October 29, 2009, 05:55:15 am »
Hello

Pleas try to update device list before access to it:

Code: [Select]
nrHid1:=TnrHid.Create(nil);
nrHid1.Update();

Roman Novgorodov
DeepSoftware llc - The professional components for Delphi/CBuilder/.NET. The high quality custom software development.
Forums.nrCommLib.Com - DeepSoftware Tech Support Forum.

ChrBlack

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: How to enumerate without TnrDeviceBox ?
« Reply #2 on: October 29, 2009, 08:06:10 am »
Hello Roman!

It works! Thank you very much. I owe you with a mug of beer ;-)