Author Topic: WMDeviceChange  (Read 1974 times)

pipy71

  • Newbie
  • *
  • Posts: 11
    • View Profile
WMDeviceChange
« on: March 21, 2011, 04:36:40 pm »
I have nrDeviceBox on a form

I am having trouble getting the list of available com ports to update correctly when I remove a USB port.

Plugging in a new USB to serial com port works fine, its detected and shows in the nrDeviceBox correctly.

However when the USB device is unplugged from computer the removed port still shows in the nrDeviceBox!

What's the correct method for updating the nrDeviceBox when using WMDeviceChange so that removed ports don't show any more?

Thanks

Roman Novgorodov

  • Engineer
  • Administrator
  • Hero Member
  • *****
  • Posts: 994
  • we will win
    • View Profile
    • Forums.nrCommLib.Com
Re: WMDeviceChange
« Reply #1 on: March 21, 2011, 06:58:36 pm »
Hello

You can call nrComm.Update method

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

pipy71

  • Newbie
  • *
  • Posts: 11
    • View Profile
Re: WMDeviceChange
« Reply #2 on: March 22, 2011, 09:08:15 am »
Hello

I have tried but it wont remove the com port from the nrDeviceBox1 list when I unplug the USB cable..

Code: [Select]

public
    { Public declarations }
    procedure WMDeviceChange(var Msg:TMessage); message WM_DEVICECHANGE;
  end;

procedure MyViewer.WMDeviceChange(var Msg: TMessage);
begin
  nrDeviceBox1.clear;
  nrComm1.WMDeviceChange(Msg);
  nrComm1.update;
  nrcomm1.DeviceIndex := 0;


Regards

Roman Novgorodov

  • Engineer
  • Administrator
  • Hero Member
  • *****
  • Posts: 994
  • we will win
    • View Profile
    • Forums.nrCommLib.Com
Re: WMDeviceChange
« Reply #3 on: March 22, 2011, 12:05:11 pm »
Hello

Please check that nrComm.EnumPorts is epFullPresent value.

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