Delphi COM串口打印演示

Delphi COM串口打印演示,第1张

概述unit Unit1; //Download by http://www.NewXing.com interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, ExtCtrls, RzPanel, StdCtrls, RzCmboBx, RzButton, Com

unit Unit1;
//Download by http://www.NewXing.com
interface

uses
windows,Messages,SysUtils,Variants,Classes,Graphics,Controls,Forms,
Dialogs,ExtCtrls,RzPanel,StdCtrls,RzCmboBx,Rzbutton,ComCtrls,
RzEdit,oleCtrls,MSCommlib_TLB;

type
TForm1 = class(TForm)
mscm1: TMSComm;
edt1: TRzRichEdit;
rzbtbtn1: TRzBitBtn;
cbb1: TRzComboBox;
rzpnl1: TRzPanel;
rzbtbtn2: TRzBitBtn;
rzbtbtn3: TRzBitBtn;
edt2: TEdit;
procedure mscm1Comm(Sender: TObject);
procedure rzbtbtn1Click(Sender: TObject);
procedure rzbtbtn2Click(Sender: TObject);
procedure rzbtbtn3Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.mscm1Comm(Sender: TObject);
var
n : Integer;
rx :Integer;
recstr : Variant;
t : string;
i : Integer;
tr : Integer;
strintext :string;
begin
recstr:= copy(mscm1.input,1,2);
strintext:= recstr ;
edt2.Text:=Trim(strintext);
// if mscm1.CommEvent =comEventBreak then
// begin
// edt1.Text:=‘PRINT‘;
// end;
{
if mscm1.CommEvent = ComEventRxParity then
tr:=1;
if mscm1.CommEvent = 2 then
begin
n:=mscm1.InBufferCount;
inc(rx,n);
recstr :=mscm1.input;
if mscm1.inputMode = 0 then
begin
t:=‘‘;
t:= recstr;
if t<>‘‘ then
begin
for i:= 0 to n do
begin
if t[i]=‘?‘ then
begin
tr:=1
end
else
if (tr=0) then
begin
strintext:=strintext+‘ ‘ + IntToHex(Byte(t[i]),2)
end
else
begin
strintext:= strintext+‘ ‘ + IntToHex(Byte(t[i])+126,2) ;
tr:=0;
end;
end;
end;
end;
end; }
end;

procedure TForm1.rzbtbtn1Click(Sender: TObject);
begin
if mscm1.Portopen then
begin
mscm1.Portopen:=False;
end;
try
mscm1.CommPort:=1;
mscm1.Settings:=‘9600,N,8,1‘;
mscm1.inputLen:=0; // default 0
mscm1.RThreshold:=1;
mscm1.inputMode:=cominputModeText;
mscm1.inputLen:=0;
mscm1.Portopen:=True;
except
mscm1.Portopen:=False;
end;
// end
end;

procedure TForm1.rzbtbtn2Click(Sender: TObject);
begin
Application.Terminate;
end;

procedure TForm1.rzbtbtn3Click(Sender: TObject);
begin
if mscm1.Portopen = True then
mscm1.Portopen := False;
end;

end.

总结

以上是内存溢出为你收集整理的Delphi COM串口打印演示全部内容,希望文章能够帮你解决Delphi COM串口打印演示所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/langs/1234200.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-06
下一篇 2022-06-06

发表评论

登录后才能评论

评论列表(0条)

保存