📄 unit1.pas
字号:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, MotoP2KMode, StdCtrls, ComCtrls, MotoATMode, USBCtrls, Grids, MotoSysUtils;
type
TForm1 = class(TForm)
MotoP2KMode1: TMotoP2KMode;
GroupBox1: TGroupBox;
ListBox1: TListBox;
GroupBox3: TGroupBox;
Label1: TLabel;
Label2: TLabel;
Button1: TButton;
Button2: TButton;
Button3: TButton;
Button6: TButton;
MotoATMode1: TMotoATMode;
CheckBox1: TCheckBox;
OpenDialog1: TOpenDialog;
Label3: TLabel;
Label4: TLabel;
Edit1: TEdit;
Edit2: TEdit;
Button4: TButton;
StringGrid1: TStringGrid;
Button5: TButton;
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure ListBox1Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure MotoP2KMode1Arrival(Sender: TObject);
procedure MotoP2KMode1Remove(Sender: TObject);
procedure Button6Click(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure MotoATMode1Arrival(Sender: TObject);
procedure Button4Click(Sender: TObject);
procedure Button5Click(Sender: TObject);
private
procedure ViewStringGrid(Buff:TSeemBuff; Size:integer);
public
{ Public declarations }
end;
var
Form1: TForm1;
Load : boolean = false;
implementation
{$R *.dfm}
procedure GetDevises;
var i : integer;
Dev : TMotoP2KModemItem;
begin
with Form1 do begin
ListBox1.Clear;
for i:=0 to MotoP2KMode1.DeviceList.Count-1 do begin
Dev := MotoP2KMode1.DeviceList.Items[i];
if Dev=nil then continue;
ListBox1.Items.Add(Dev.ModemInfo.DeviceDescr);
end;
if ListBox1.Items.Count>0 then
ListBox1.ItemIndex := 0;
ListBox1.OnClick(nil);
end;
end;
procedure TForm1.ViewStringGrid(Buff:TSeemBuff; Size:integer);
var i,C,R,MC,MR:integer;
S:string;
begin
if size<=0 then exit;
StringGrid1.FixedCols := 1;
StringGrid1.FixedRows := 1;
for i:=1 to 18 do begin
S := INTToHex(i-1,2);
StringGrid1.Cells[i,0] := S;
StringGrid1.Cells[0,i] := S+'0';
end;
C := 0;
R := 0;
MC:= 0;
MR:= 0;
for i:=0 to Size do begin
if (i Mod 16)=0 then begin
INC(R);
C := 1;
end else
INC(C);
if @Buff=nil then
S := ''
else
S := IntToHex(Buff[i],2);
StringGrid1.Cells[C,R] := S;
if C>MC then MC := C;
if R>MR then MR := R;
end;
StringGrid1.ColCount := MC+1;
StringGrid1.RowCount := MR+1;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
Constraints.MinHeight := Height;
Constraints.MaxHeight := Height;
Constraints.MinWidth := Width;
Constraints.MaxWidth := Width;
GetDevises;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
GetDevises;
end;
procedure TForm1.ListBox1Click(Sender: TObject);
var item : TMotoP2KModemItem;
begin
Label2.Caption := 'DisConnect';
if (ListBox1.ItemIndex<0) and (ListBox1.ItemIndex>=ListBox1.Count) then exit;
// Get
item := MotoP2KMode1.DeviceList.Items[ListBox1.ItemIndex];
if item=nil then exit;
// Status
if item.IsOpened then
Label2.Caption := 'Connect'
else
Label2.Caption := 'DisConnect';
end;
procedure TForm1.Button2Click(Sender: TObject);
var item : TMotoP2KModemItem;
begin
if (ListBox1.ItemIndex<0) and (ListBox1.ItemIndex>=ListBox1.Count) then exit;
item := MotoP2KMode1.DeviceList.Items[ListBox1.ItemIndex];
if item=nil then exit;
item.Open;
ListBox1.OnClick(nil);
end;
procedure TForm1.Button3Click(Sender: TObject);
var item : TMotoP2KModemItem;
begin
if (ListBox1.ItemIndex<0) and (ListBox1.ItemIndex>=ListBox1.Count) then exit;
item := MotoP2KMode1.DeviceList.Items[ListBox1.ItemIndex];
if item=nil then exit;
item.Close;
ListBox1.OnClick(nil);
end;
procedure TForm1.MotoP2KMode1Arrival(Sender: TObject);
begin
GetDevises;
end;
procedure TForm1.MotoP2KMode1Remove(Sender: TObject);
begin
GetDevises;
end;
procedure TForm1.Button6Click(Sender: TObject);
var i:integer;
s:string;
begin
if MotoATMode1.DeviceList.Count<1 then begin
ShowMEssage('玉蝠铋耱忄 礤 磬殇屙
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -