📄 usagesmain.pas
字号:
unit UsagesMain;
interface
uses
Windows, SysUtils, Classes, Controls, Forms, StdCtrls, Buttons,
JvHidControllerClass, HID, HidUsage;
type
TUsagesForm = class(TForm)
DevListBox: TListBox;
HidCtl: TJvHidDeviceController;
Info: TSpeedButton;
Description: TLabel;
procedure HidCtlDeviceChange(Sender: TObject);
function HidCtlEnumerate(HidDev: TJvHidDevice;
const Idx: Integer): Boolean;
procedure InfoClick(Sender: TObject);
public
end;
var
UsagesForm: TUsagesForm;
implementation
uses
Info;
{$R *.dfm}
procedure TUsagesForm.HidCtlDeviceChange(Sender: TObject);
var
Dev: TJvHidDevice;
I: Integer;
begin
// hand back all the devices assigned to the list entries
for I := 0 to DevListBox.Items.Count - 1 do
begin
Dev := TJvHidDevice(DevListBox.Items.Objects[I]);
HidCtl.CheckIn(Dev);
DevListBox.Items.Objects[I] := nil;
end;
DevListBox.Items.Clear;
HidCtl.Enumerate;
end;
function TUsagesForm.HidCtlEnumerate(HidDev: TJvHidDevice;
const Idx: Integer): Boolean;
var
Dev: TJvHidDevice;
N: Integer;
begin
// add a descriptive entry to the listbox for the device
if HidDev.ProductName <> '' then
N := DevListBox.Items.Add(HidDev.ProductName)
else
N := DevListBox.Items.Add(Format('Device VID=%x PID=%x',
[HidDev.Attributes.VendorID, HidDev.Attributes.ProductID]));
// check out the device and assign it to the list entry
HidCtl.CheckOutByIndex(Dev, Idx);
DevListBox.Items.Objects[N] := Dev;
Result := True;
end;
procedure TUsagesForm.InfoClick(Sender: TObject);
begin
// show info about the device assigned to the list entry
if (DevListBox.Items.Count > 0) and (DevListBox.ItemIndex >= 0) then
with TInfoForm.Create(Self) do
begin
Dev := TJvHidDevice(DevListBox.Items.Objects[DevListBox.ItemIndex]);
ShowModal;
Free;
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -