Author: Maarten de Haan
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.
1
2 //----------------------------------------------------------------------
3 // This routine is published by me before...
4
5 procedure PrintRawStr(const S: ANSIString);
6
7 uses
8 Printers, WinSpool, Dialogs;
9
10 var
11 Handle: THandle;
12 dwN: DWORD;
13 diDocInfo1: TDocInfo1;
14 bP: BYTE;
15 sDefaultPrinter: string;
16
17 begin
18 sDefaultPrinter := '';
19 if Printer.Printers.Count > 0 then
20 begin
21 sDefaultPrinter := Printer.Printers[Printer.PrinterIndex];
22 //uses Printers, get default printer
23 bP := Pos(' on ', sDefaultPrinter);
24 if bP > 0 then
25 sDefaultPrinter := Copy(sDefaultPrinter, 1, bP - 1);
26 end;
27
28 if Length(S) = 0 then
29 Exit;
30
31 if not OpenPrinter(PChar(sDefaultPrinter), Handle, nil) then
32 begin
33 case GetLastError of
34 87: ShowMessage('Printer name does not exists.');
35 else
36 ShowMessage('Error ' + IntToStr(GetLastError)); // Uses Dialogs
37 end;
38 Exit;
39 end;
40
41 with diDocInfo1 do
42 begin
43 pDocName := PChar('My Print Job'); // Visible in the spooler window
44 pOutputFile := nil;
45 pDataType := 'RAW';
46 end;
47
48 StartDocPrinter(Handle, 1, @diDocInfo1);
49 StartPagePrinter(Handle);
50 WritePrinter(Handle, PChar(S), Length(S), dwN);
51 EndPagePrinter(Handle);
52 EndDocPrinter(Handle);
53 ClosePrinter(Handle);
54 end;
55 //----------------------------------------------------------------------
56
57 procedure ChangeLaserReadyMessage(S: string);
58
59 const
60 InitStr: string = #27 + '%-12345X@PJL RDYMSG DISPLAY="';
61 ExitStr: string = '"' + #13 + #10 + #27 + '%-12345X' + #13 + #10;
62
63 begin
64 PrintRawStr(InitStr + S + ExitStr);
65 end;
66 //----------------------------------------------------------------------
|