📄 wbta_macro.pas
字号:
unit WBTA_Macro;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, ExtCtrls, CPortCtl;
type
TMacroForm = class(TForm)
Label1: TLabel;
Edit1: TEdit;
KiesEditor: TButton;
Button2: TButton;
Button3: TButton;
GroupBox1: TGroupBox;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
Label7: TLabel;
Label8: TLabel;
Label9: TLabel;
Label10: TLabel;
Label11: TLabel;
Label12: TLabel;
Label13: TLabel;
Label14: TLabel;
Label15: TLabel;
Label16: TLabel;
Label17: TLabel;
Label22: TLabel;
Label23: TLabel;
Label24: TLabel;
Label25: TLabel;
Edit2: TEdit;
OpenDialog1: TOpenDialog;
Label18: TLabel;
Edit3: TEdit;
KiesLogFile: TButton;
COMSelect: TRadioGroup;
BaudSelect: TRadioGroup;
EmuSelect: TRadioGroup;
procedure Edit2KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure EditToLabel;
procedure LabelToEdit;
procedure FormCreate(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure Label5Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure FormActivate(Sender: TObject);
procedure KiesEditorClick(Sender: TObject);
procedure KiesLogFileClick(Sender: TObject);
procedure Edit2KeyPress(Sender: TObject; var Key: Char);
private
{ Private declarations }
EditPos : Integer;
public
{ Public declarations }
end;
var
MacroForm: TMacroForm;
implementation
uses WBTAUnit1, WBTA_Var ;
{$R *.DFM}
procedure TMacroForm.EditToLabel;
begin
case EditPos of
0 : Label3.Caption := Edit2.Text;
1 : Label5.Caption := Edit2.Text;
2 : Label9.Caption := Edit2.Text;
3 : Label7.Caption := Edit2.Text;
4 : Label16.Caption := Edit2.Text;
5 : Label17.Caption := Edit2.Text;
6 : Label13.Caption := Edit2.Text;
7 : Label11.Caption := Edit2.Text;
8 : Label24.Caption := Edit2.Text;
9 : Label25.Caption := Edit2.Text;
end;
end;
procedure TMacroForm.LabelToEdit;
begin
case EditPos of
0 : Edit2.Text := Label3.Caption;
1 : Edit2.Text := Label5.Caption;
2 : Edit2.Text := Label9.Caption;
3 : Edit2.Text := Label7.Caption;
4 : Edit2.Text := Label16.Caption;
5 : Edit2.Text := Label17.Caption;
6 : Edit2.Text := Label13.Caption;
7 : Edit2.Text := Label11.Caption;
8 : Edit2.Text := Label24.Caption;
9 : Edit2.Text := Label25.Caption;
end;
end;
procedure TMacroForm.FormCreate(Sender: TObject);
begin
Edit2.Height := 14;
EditPos := 0;
Label3.Caption := Alt0;
Label5.Caption := Alt1;
Label9.Caption := Alt2;
Label7.Caption := Alt3;
Label16.Caption := Alt4;
Label17.Caption := Alt5;
Label13.Caption := Alt6;
Label11.Caption := Alt7;
Label24.Caption := Alt8;
Label25.Caption := Alt9;
Edit1.Text := Editor;
Edit2.Text := Label3.Caption;
Edit3.Text := LogFile;
// com parameters function IndexOf(const S: string): Integer; override;
If ComStrl.IndexOf('COM1') = -1 then
ComSelect.Controls[0].Enabled := False;
If ComStrl.IndexOf('COM2') = -1 then
ComSelect.Controls[1].Enabled := False;
If ComStrl.IndexOf('COM3') = -1 then
ComSelect.Controls[2].Enabled := False;
If ComStrl.IndexOf('COM4') = -1 then
ComSelect.Controls[3].Enabled := False;
// ComSelect.Items := ComStrl; // no more then found
ComSelect.ItemIndex := COMPort - 1;
Case BaudRate of
300 : BaudSelect.ItemIndex := 0;
1200 : BaudSelect.ItemIndex := 1;
2400 : BaudSelect.ItemIndex := 2;
9600 : BaudSelect.ItemIndex := 3;
19200 : BaudSelect.ItemIndex := 4;
38400 : BaudSelect.ItemIndex := 5;
end;
EmuSelect.ItemIndex := Emulation;
end;
procedure TMacroForm.Edit2KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
If Key = VK_RETURN then Key := VK_DOWN;
If Key = VK_RETURN then
Key := VK_DOWN;
If not (Key in [VK_DOWN,VK_UP]) then exit;
EditToLabel;
If Key = VK_DOWN then begin
EditPos := EditPos + 1;
If EditPos > 9 then EditPos := 9;
Key := 0;
end;
If Key = VK_UP then begin
EditPos := EditPos - 1;
If EditPos < 0 then EditPos := 0;
Key := 0;
end;
LabelToEdit;
Edit2.Top := (EditPos * 14 ) + 20;
end;
procedure TMacroForm.FormShow(Sender: TObject);
begin
MacroForm.Left := Form1.Left + (Form1.Width - MacroForm.Width) div 2;
MacroForm.Top := Form1.Top + (Form1.Height - MacroForm.Height) div 2;
MacroForm.Caption := ' Unit Setup -- ' + UnitStr;
Edit3.Height := 20;
Edit1.Height := 20;
end;
procedure TMacroForm.Label5Click(Sender: TObject);
begin
EditToLabel; // save first the old one
Edit2.Height := 15;
EditPos := (Sender as TLabel).tag; // calculate new position
Edit2.Top := (EditPos * 14)+20;
LabelToEdit; // data to edit
end;
procedure TMacroForm.Button2Click(Sender: TObject);
begin
EditToLabel;
Alt0 := Label3.Caption;
Alt1 := Label5.Caption;
Alt2 := Label9.Caption;
Alt3 := Label7.Caption;
Alt4 := Label16.Caption;
Alt5 := Label17.Caption;
Alt6 := Label13.Caption;
Alt7 := Label11.Caption;
Alt8 := Label24.Caption;
Alt9 := Label25.Caption;
Editor := Edit1.Text;
LogFile := Edit3.Text;
If ExtractFileExt(LogFile) = '' then
LogFile := LogFile + '.LOG';
Form1.SpeedButton3.Hint := 'Log file = '+ LogFile;
// com parameters
COMPort := ComSelect.ItemIndex + 1;
Case BaudSelect.ItemIndex of
0 : Baudrate := 300;
1 : Baudrate := 1200;
2 : Baudrate := 2400;
3 : Baudrate := 9600;
4 : Baudrate := 19200;
5 : Baudrate := 38400;
end;
Emulation := EmuSelect.ItemIndex;
Case EmuSelect.ItemIndex of
0 : Form1.ComTerminal1.Emulation := teNone;
1 : Form1.ComTerminal1.Emulation := teVT100orANSI;
2 : Form1.ComTerminal1.Emulation := teVT52;
3 : Form1.ComTerminal1.Emulation := teVT100orANSI;
end;
end;
procedure TMacroForm.FormActivate(Sender: TObject);
begin
Edit2.SetFocus;
end;
procedure TMacroForm.KiesEditorClick(Sender: TObject);
begin
OpenDialog1.Filter := 'Text Editor (*.EXE)|*.EXE';
OpenDialog1.DefaultExt := 'EXE';
If OpenDialog1.Execute then begin
Edit1.Text := OpenDialog1.Filename;
end;
end;
procedure TMacroForm.KiesLogFileClick(Sender: TObject);
begin
OpenDialog1.Filter := 'terminal log files (*.LOG)|*.LOG';
OpenDialog1.DefaultExt := 'LOG';
If OpenDialog1.Execute then begin
Edit3.Text := OpenDialog1.Filename;
end;
end;
procedure TMacroForm.Edit2KeyPress(Sender: TObject; var Key: Char);
begin
If Key = #13 then
key := #0;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -