Delphi下POS机控制钱箱,客显,打印机,小票打印
1、控制POS机的客户显示屏
procedure TFrmMain.ShowMoney(Money_Port: String;Money_String:String);
//Moneey_Port 顾显接口Com1 or Com2 Money_String 顾显显示的内容
var
PrnFileName:TextFile;
begin
Assignfile(PrnFileName,Money_Port);
printer.Canvas.Font.Name:='宋体';
printer.Canvas.Font.Size:=8;
printer.Canvas.Font.Charset:=GB2312_CHARSET;
Rewrite(PrnFileName);
write(PRNFileName,chr(12)); //清除顾显
write(PRNFileName,chr(27)+chr(81)+chr(65)+Money_String+chR(13)); //显示信息
CloseFile(PRNFileName);
end;
2、不换页走纸的打印
procedure TFrmMain.AddPrintStrings(Strings: TStrings);
var
Prn: TextFile;
i: word;
begin
Assignfile(Prn,'lpt1');
printer.Canvas.Font.Name:='宋体';
printer.Canvas.Font.Size:=9;
printer.Canvas.Font.Charset:=GB2312_CHARSET;
try
Rewrite(Prn);
try
for i := 0 to Strings.Count - 1 do
writeln(Prn, Strings.Strings[i]);
finally
CloseFile(Prn);
end;
except
on EInOutError do
MessageBox(Handle,PChar('文本打印出错!'),'警告',MB_ICONEXCLAMATION or MB_OK);
end;
end;
3、走纸换页的打印
procedure TFrmMain.PrintStrings(Strings: TStrings);
var
Prn: TextFile;
i: word;
begin
AssignPrn(Prn);
try
Rewrite(Prn);
printer.Canvas.Font.Name:='宋体';
printer.Canvas.Font.Size:=9;
printer.Canvas.Font.Charset:=GB2312_CHARSET;
try
for i := 0 to Strings.Count - 1 do
writeln(Prn, Strings.Strings[i]);
finally
CloseFile(Prn);
end;
except
on EInOutError do
MessageBox(Handle,PChar('文本打印出错!'),'警告',MB_ICONEXCLAMATION or MB_OK);
end;
end;
4、打开钱箱
procedure TFrmMain.OpenMoneyBox;
Var F:TextFile;
PDStr:string;
begin
//弹出钱箱功能
PDStr:= Chr(27)+'p'+Chr(0)+Chr(60)+Chr(255);
AssignFile(F, 'LPT1');
Rewrite(F);
Write(F, PDStr);
CloseFile(F);
end;
posted on 2011-01-19 13:47 Edison-技术 阅读(2422) 评论(0) 编辑 收藏 举报