中国程序员联盟 正在重新改版中ing 不便之处还请见谅 改版后将内容涉及java delphi .net php
 
  首页 | 数据库开发 | 网络通讯 | 多线程 | 多媒体开发 | 图像处理 | 程序人生 | 系统函数 | 控件开发 | Web服务
 
  当前位置:笨鱼delphi技术网>数据库开发>打印报表>文章内容

delphi 如何发改变HP打印机消息

来源:国外 关于:Maarten de Haan 发布时间:2007-07-06   [收藏] [推荐]
Problem/Question/Abstract:
How to change the ReadyMessage of HP-LaserJet printers with a LCD display?
Answer:
This works only on HP-LaserJet printers, which have a two line 16 character LCD display. F.i. on a HP LaserJet 4000, HP LaserJet 5000 (N). In this LCD-display you normally find messages like: READY, or PAPER OUT IN BIN 3 or something like that. With this small routine you can alter the ready message into your own. It will stay there until you switch the printer off (or change the ready message with this program). The message should be no longer than two lines of 16 characters each. Remember that it will be truncated after 16 characters, the rest of the line will be on the next line of 16 characters on the LCD display.
//----------------------------------------------------------------------
// This routine is published by me before...
procedure PrintRawStr(const S: ANSIString);
Uses
  Printers, WinSpool, Dialogs;
var
  Handle: THandle;
  dwN: DWORD;
  diDocInfo1: TDocInfo1;
  bP: BYTE;
  sDefaultPrinter: string;
begin
  sDefaultPrinter := '';
  if Printer.Printers.Count > 0 then
  begin
    sDefaultPrinter := Printer.Printers[Printer.PrinterIndex];
    //uses Printers, get default printer
    bP := Pos(' on ', sDefaultPrinter);
    if bP > 0 then
      sDefaultPrinter := Copy(sDefaultPrinter, 1, bP - 1);
  end;
  if Length(S) = 0 then
    Exit;
  if not OpenPrinter(PChar(sDefaultPrinter), Handle, nil) then
  begin
    case GetLastError of
      87: ShowMessage('Printer name does not exists.');
    else
      ShowMessage('Error ' + IntToStr(GetLastError)); // Uses Dialogs
    end;
    Exit;
  end;
  with diDocInfo1 do
  begin
    pDocName := PChar('My Print Job'); // Visible in the spooler window
    pOutputFile := nil;
    pDataType := 'RAW';
  end;
  StartDocPrinter(Handle, 1, @diDocInfo1);
  StartPagePrinter(Handle);
  WritePrinter(Handle, PChar(S), Length(S), dwN);
  EndPagePrinter(Handle);
  EndDocPrinter(Handle);
  ClosePrinter(Handle);
end;
//----------------------------------------------------------------------
procedure ChangeLaserReadyMessage(S: string);
const
  InitStr: string = #27 +
'%-12345X@PJL RDYMSG DISPLAY="';
  ExitStr: string = '"' + #13 + #10 + #27 + '%-12345X' + #13 + #10;
begin
  PrintRawStr(InitStr + S + ExitStr);
end;
//----------------------------------------------------------------------

[浏览: 次]   
上一篇:delphi 打印LabelsVCL组件   下一篇:delphi 如何保存打印机信息到注册表
[收藏] [推荐] [返回顶部] [打印本页] [关闭窗口]  
    评论加载中…
google adsense热点文章
·delphi 获取打印机状态
·delphi 打印时改变纸张大小
·delphi 判断打印机能否打印的PostScrip
·delphi 检测存在打印机
·delphi Tmemo,TstringList,Tstrings打
·delphi 如何保存打印机信息到注册表
·delphi 判断系统是否有打印机连接
·delphi 在打印中间改变打印设置
·delphi 获取打印驱动,打印端口名
·delphi 使用打印机内置字体打印
·delphi 改变打印机的打印端口
·delphi 打印LabelsVCL组件
     delphi技术网 | firefox 下载 | Avant Browser下载 | dedecms 技术网 | drupal 爱好者 | php 技术网
  Copyright@www.delphichm.com,2006-2009.All Rights Reserved.
 
程序员联盟 | delphi Java .net|QQ:707102932