读书人

delphi 写的串口打印机程序红色部分有

发布时间: 2013-12-13 00:50:19 作者: rapoo

delphi 写的串口打印机程序红色部分有点不懂请高手指点--初学者
procedure PrintPnl_ID_CELL(aPnl_ID,aExtract,aAddCition,aWork_ctr,aMach_id:string;
aX,aY:Integer);stdcall;

var So:array [0..12] of string;
s:string;
i:integer;
x,y:Integer;
x1,x2,y1,y2:string;
wm:string;
frm:TFrmPrintSet;
txtPnl_id :string ; //列印panel文本
begin
txtPnl_id := Trim(aPnl_id);

try
//正常打印时ax,ay传入0
if aX=0 then
begin
wm:=awork_ctr+amach_id; //站别线别
//ShowMessage(wm);
if CheckIniSection(wm,'')=false then
//读取该站别线别的打印机参数
//如果读不到参数则打开设置窗口
begin
frm:=TFrmPrintSet.Create(nil);
frm.work_ctr:=aWork_ctr;
frm.mach_id :=aMach_id;
frm.ShowModal;
//Exit;
end;
x:=StrToInt(ReadFromIni(wm,'POSX','500',''));
y:=StrToInt(ReadFromIni(wm,'POSY','10',''));
end
else //测试打印时传入测试时的X/Y轴坐标值
begin
x:=aX;
y:=aY;
end;

//如果端口未打开则打开指定端口
if GBopen=false then OpenPort(aWork_ctr,aMach_id);
x1:=IntToStr(x);
//x2:=IntToStr(x+71) ;
//x2:=IntToStr(x+105) ; //Gsmall 2008/5/10
x2:=IntToStr(x+25) ; //SM SM
//
//y1:=IntToStr(y);
Y1:=INTTOSTR(Y); //SM SM
//y2:=IntToStr(y+63);
//y2:=IntToStr(y+35); //small
Y2:=INTTOSTR(Y+45); //SM SM

so[0]:=chr(2);
so[1]:=chr(27)+'A';
so[2]:=chr(27)+'H'+x1;
so[3]:=chr(27)+'V'+y1;
//so[4]:=chr(27)+'P02L0303';
//so[5]:=chr(27)+'D102058'+'*'+aPnl_ID+'*';
//so[5]:=chr(27)+'D102032'+'*'+aPnl_ID+'*'; 2008/5/10
so[5]:=chr(27)+'BG01040'+txtPnl_id; //SM SM
so[6]:=chr(27)+'H'+x2;
so[7]:=chr(27)+'V'+y2;
so[8]:=chr(27)+'P01'+chr(27)+'L0101';
so[9]:=chr(27)+'S'+aExtract+txtPnl_id+aExtract+aAddCition;
so[10]:=chr(27)+'Q01';
So[11]:=Chr(27)+'Z';
so[12]:=chr(3);

for i := 0 to 12 do
begin
s:=s+so[i];


end;
sio_flush(GCommData.Port,2);
sio_write(GCommData.Port,PChar(s),length(s));
ClosePort
except
ClosePort;
end;
end;
[解决办法]
这个得看你发往 打印机的指令表,去查询此指令的含义了。

读书人网 >.NET

热点推荐