Estoy haciendo un programa para mandar imprimir una nota de venta en una impresora termica, este programa manda codigos de escape para el corte del papel y apertura de cajon, y en delphi 2007 funciona de maravilla, si este mismo programa lo ejecuto desde delphi 2010, no me imprime de manera correcta incluso los renglones de texto los imprime incompletos.
Para esto estoy utilizando el siguiente codigo de prueba (delphi 2007 OK, delphi 2010 MAL):
Alguna sugerencia del motivo de la falla?
delphi
unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Printers, Dialogs, StdCtrls; type TPrnBuffRec = record bufflength: Word; Buff_1: array[0..255] of Char; end; TForm1 = class(TForm) Button1: TButton; procedure Button1Click(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form1: TForm1; implementation {$R *.dfm} function DirectToPrinter(S: string): Boolean; var Buff: TPrnBuffRec; TestInt: Integer; begin TestInt := PassThrough; if Escape(Printer.Handle, QUERYESCSUPPORT, SizeOf(TESTINT), @testint, nil) > 0 then begin StrPCopy(Buff.Buff_1, S); Buff.bufflength := StrLen(Buff.Buff_1); Escape(Printer.Canvas.Handle, Passthrough, 0, @buff, nil); Result := True; end else Result := False; 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; var i:Integer; begin Printer.BeginDoc; for i := 0 to 2 do begin DirectToPrinter('This text'); DirectToPrinter(#10#13); DirectToPrinter(#27#105); //Corte de papel end; Printer.EndDoc; end; procedure TForm1.Button1Click(Sender: TObject); begin PrintOut; end; end.