Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sending printer escape control codes 1

Status
Not open for further replies.

kerryeven

Programmer
Mar 21, 2000
4
US
I created a CDC CreateDC to my printer. I can send text with TextOut no problem. I have an Epson 2 color printer that requires ESCr1 to be sent to it to print in red. ESCr0 prints in black. <br>
<br>
I have tried dc.Escape(PASSTHROUGH,0,cstrESC,0,NULL); with no success. (cstrESC = char(27) etc. to build the string.<br>
<br>
Anybody know how to send and escape code sequence to a printer?
 
Wouldn't the Epson printer driver handle this issue for you? In theory, you should be able to change the current color to red (using GDI functions), and it should just happen -- everything should appear in red, until you change it back to black.<br>
<br>
Chip H.<br>

 
Thanks Chip:<br>
<br>
I did find a way. Instead of using a CDC::CreateDevice, I used a newer printer API available in WinSpool.h<br>
<br>
I was then able to OpenPrinter and WritePrinter. WritePrinter goes directly to the printer bypassing the driver. Works very well. Basically:<br>
<br>
HANDLE hPrinter;<br>
DOC_INFO_1 DocInfo;<br>
DWORD dwJob;<br>
DWORD dwBytesWritten;<br>
<br>
<br>
DocInfo.pDocName = &quot;Whatever&quot;;<br>
DocInfo.pOutputFile = NULL;<br>
DocInfo.pDatatype = &quot;RAW&quot;;<br>
<br>
dwJob = StartDocPrinter( hPrinter, 1, (LPBYTE)&DocInfo);<br>
StartPagePrinter (hPrinter);<br>
wchar_t wcharESC = char(27);<br>
WritePrinter (hPrinter,(LPBYTE)&wcharESC,1,&dwBytesWritten);<br>
...<br>
EndPagePrinter( hPrinter);<br>
EndDocPrinter( hPrinter);<br>
CLosePrinter( hPrinter);<br>
<br>
The Epson Point of Sale drivers are not up to consumer grade so you have to send the escape sequences in code directly to the printer.<br>
<br>
Thanks anyway,<br>
<br>
Kerry<br>

 
Kerry,<br>
<br>
The last sentence of your post caught my eye. Have you tried using the OLE for POS (OPOS) drivers from Epson? Depending on what kind of printer you are trying to support (my experience is with the TM-H5000 and TM-H6000) OPOS may be the way to go...<br>
<br>
Good luck,<br>
<p>Pat Gleason<br><a href=mailto:gleason@megsinet.net>gleason@megsinet.net</a><br><a href= > </a><br>
 
Thanks Pat:<br><br>Yes I have looked into OPOS.&nbsp;&nbsp;I found no way to utilize networked printers with OPOS so I gave up on it.&nbsp;&nbsp;I have print destinations which are on different computers than the issuing computer.&nbsp;&nbsp;I found a discussion on Microsoft about OPOS in which the community did not want to incorporate DCOM as it would require a rewrite of OPOS modules.&nbsp;&nbsp;<br><br>Kerry
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top