📄 reveivecom.pas
字号:
unit reveivecom;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, OleCtrls, MSCommLib_TLB, ExtCtrls;
type
TForm1 = class(TForm)
GroupBox1: TGroupBox;
RadioButton1: TRadioButton;
RadioButton2: TRadioButton;
GroupBox2: TGroupBox;
ComboBox1: TComboBox;
Memo1: TMemo;
Button2: TButton;
Button3: TButton;
MSComm1: TMSComm;
Label1: TLabel;
procedure Button3Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure mscomm1comm(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button3Click(Sender: TObject);
begin
mscomm1.PortOpen :=false;
mscomm1.DTREnable :=false;
mscomm1.RTSEnable :=false;
close;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
mscomm1.InBufferCount :=0;
mscomm1.InputLen :=0;
mscomm1.RThreshold :=1;
mscomm1.SThreshold :=1;
mscomm1.Settings :=combobox1.Text ;
if radiobutton1.Checked =true then
begin
mscomm1.CommPort :=1;
end
else
mscomm1.CommPort :=2;
mscomm1.PortOpen :=true;
mscomm1.DTREnable :=true;
mscomm1.RTSEnable :=true;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
if mscomm1.PortOpen =true then
begin
mscomm1.PortOpen :=false;
mscomm1.DTREnable :=false;
mscomm1.RTSEnable :=false;
end;
mscomm1.Settings :=combobox1.Text ;
if radiobutton1.Checked =true then
begin
mscomm1.CommPort :=1;
end
else
mscomm1.CommPort :=2;
mscomm1.PortOpen :=true;
mscomm1.DTREnable :=true;
mscomm1.RTSEnable :=true;
end;
procedure TForm1.mscomm1comm(Sender: TObject);
var
str1:olevariant;
s1:string;
begin
if mscomm1.CommEvent =2 then
begin
str1:=mscomm1.Input ;
label1.Caption :=str1;
s1:=copy(str1,1,8);
memo1.Text :=memo1.Text +str1 ;
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -