CPB Mailing List
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Printer Escape function blues
I'm trying to send PCL commands to an HP 6P printer, using the windows Escape()
function, via the PASSTHROUGH option. The code follows.
_______________________________________________
char Tray2[] = { 0x1B, '&', 'l', '1', 'H', '\0' } ;
char Tray1[] = { 0x1B, '&', 'l', '4', 'H', '\0' } ;
void __fastcall TMainForm::SendCommand( HANDLE MyHandle, char * command )
{
int i = PASSTHROUGH ;
volatile int EscResult ;
EscResult = Escape( MyHandle, QUERYESCSUPPORT, sizeof( i ), (LPSTR)&i, NULL ) ;
EscResult = Escape( MyHandle, PASSTHROUGH, strlen( command), command, NULL ) ;
if ( EscResult <= 0 ) {
DWORD ErrorCd = GetLastError() ;
DWORD Result = FormatMessage( FORMAT_MESSAGE_FROM_SYSTEM, 0, ErrorCd, 0,
msg, sizeof(msg), NULL ) ;
throw Exception( (String)("Printer error:") + msg ) ;
}
}
//---------------------------------------------------------------------------
void __fastcall TMainForm::Button4Click(TObject *Sender)
{
HANDLE PrinterHandle = Printer()->Handle ;
SendCommand( PrinterHandle, Tray2 ) ;
}
//---------------------------------------------------------------------------
void __fastcall TMainForm::Button2Click(TObject *Sender)
{
HANDLE CanvasHandle = Printer()->Canvas->Handle ;
SendCommand( CanvasHandle, Tray1 ) ;
}
//---------------------------------------------------------------------------
The first call to Escape returns 1, indicating that the driver supports the
PASSTHROUGH option.
The second call returns 9755, and that's how many characters, starting at the
address of Tray1 or Tray2, get passed to the printer. This results in many
pages of garbage, of course.
Does anyone see what I'm doing wrong? The Escpe() calls return the same values
whether I've called BeginDoc() or not, and whether I pass the Printer handle or
the Canvas handle.
Help!
Jack Romanowicz
W Komornicki's Home Page |
Main Index |
Thread Index