Article View: borland.public.cppbuilder.nativeapi
Article #3202printing on serial port
From: Borut
Date: Fri, 28 Jul 2006 13:56
Date: Fri, 28 Jul 2006 13:56
64 lines
2876 bytes
2876 bytes
I have a problem with printing on dotmatrix printer (POS printer with 40
characters in line). It works fine with printer on paralel port (LPT1) and
with small number of lines but when I try to print 12 lines or more (on
serial), it stops printing. I use Generic / Text only printer and this
procedure:
bool xPrint(char* szPrinterName, char *szBuffer)
{
HANDLE hPrinter; // Printer handle
int iLen = strlen(szBuffer);// Length of the data to be sent
DWORD dwWritten; // How much was written to the printer
// Open printer and get a handle to it (which is saved in hPrinter)
if(OpenPrinter(szPrinterName, &hPrinter, NULL))
{
// Doc info
DOC_INFO_1 Info;
memset(&Info, 0, sizeof(Info));
Info.pDocName = "My PrintJob"; // Name of the Doc (which is shown in
the PrintManager)
Info.pOutputFile = NULL; // We're not going to write to a file so we
set it to NULL
Info.pDatatype = "RAW"; // Data are sent in RAW format (RAW and EMF
are supported by both
// Win9x and Win NT). Win NT also supports TEXT.
// Start doc
if(!StartDocPrinter(hPrinter, 1, (LPBYTE)&Info))
return false;
// Tell the printer we're starting on a new page
StartPagePrinter(hPrinter); // Write data to the printer
if(!WritePrinter(hPrinter, szBuffer, iLen, &dwWritten))
{
// An error happened while sending data to the printer.
// Use LastError to figure out what went wrong.
}
// Tell the printer we're done writing this page
EndPagePrinter(hPrinter);
// End the document
if(!EndDocPrinter(hPrinter))
return false;
// Close the printer
ClosePrinter(hPrinter);
return true;
}
else
{
return false;
}
}
what do you think is wrong?
Thx in advance
Borut
Slovenia
--
Bokosoft d.o.o.
www.bokosoft.si
info@bokosoft.si
tel: 01/546 37 20
fax: 01/546 37 21
Technical Details
Message-ID:
<44ca1798@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news2.google.com!news1.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,90aeb40ea5a6de4e,start X-Google-Attributes: gid10cc67,public X-Google-Language: ENGLISH,ASCII-7-bit Reply-To: "Borut" <borut@bokosoft.si> From: "Borut" <borut@bokosoft.si> Newsgroups: borland.public.cppbuilder.nativeapi Subject: printing on serial port Date: Fri, 28 Jul 2006 15:56:39 +0200 Lines: 66 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.2869 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2869 X-RFC2646: Format=Flowed; Original NNTP-Posting-Host: 213.157.239.90 Message-ID: <44ca1798@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1154095000 213.157.239.90 (28 Jul 2006 06:56:40 -0700) Path: arc1-ca.pugleaf.net!g2news2.google.com!news1.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail