• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Delphi下POS机

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

procedure tform1.OpenSerialPort;
var
cc:TCommConfig;
Temp:string;

begin
Temp:=\'Com\'+inttostr(RadioGroup1.ItemIndex+1);
hSerialPort:=CreateFile(PChar(Temp),GENERIC_READ or GENERIC_WRITE,0,nil,OPEN_EXISTING,0,0);
if (hSerialPort=invalid_handle_value) then
begin
MessageBox(0,\'打开串口失败\',\'\',MB_OK);
Exit;
end;
GetCommState(hSerialPort,cc.dcb);
cc.dcb.BaudRate:=CBR_9600;
cc.dcb.ByteSize:=8;
cc.dcb.Parity:=NOPARITY;
cc.dcb.StopBits:=ONESTOPBIT;
if not SetCommState(hSerialPort,cc.dcb) then
begin
ShowMessage(\'不能设置串口\');
CloseHandle(hSerialPort);
Exit;
end
else
ShowMessage(\'打开,并设置成功!\');
end;

 

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;


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap