Scalabium Software |
|
| Knowledge for your independence. | |
|
Sometimes useful to control a printer using direct command strings. It's a "DOS"-style but for some tasks this method is very useful. For example, the Epson or HP printers have a lot of internal commands which allows to change a mode of printer, define the some parameters etc. The everybody who tried to convert the DOS-programs from Pascal to Windows/Delphi, knows that the next statement WriteLn(lst, Chr(27) + '&l12D') don't work in Windows. You must use the Escape function to send data directly to the printer. View the example code which allows to send a command to printer: type
TPassThroughData = record
nLen: Word;
Data: array[0..255] of Byte;
end;
procedure PrintText(s: string);
var
PTBlock: TPassThroughData;
begin
PTBlock.nLen := Length(s);
StrPCopy(@PTBlock.Data, s);
Escape(Printer.Handle, PASSTHROUGH, 0, @PTBlock, nil);
end;
procedure PrintOut;
begin
Printer.BeginDoc;
PrintText(#27'&l12D' + 'Hello, World!');
Printer.EndDoc;
end;
|
|
||||||||||||||||||||||||||||||||||||
![]() |
Copyrightc 1998-2008, Scalabium
Software. All rights reserved. |
July 3, 2000 |