Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How do you intercept USB printer error messages when using StartDoc()/EndDoc()?

13 views
Skip to first unread message

kean...@live.co.uk

unread,
Mar 4, 2009, 11:27:48 AM3/4/09
to
Hi,

I hope someone can point me in the correct direction regarding the
printing problem I am having below:

Setup:
Win CE 5.0 with all QFEs installed to Jan '09
GENE 6315 board with Via Mark processor
Debug image with KITL enabled
>>Trying to print from a custom application.

I have written a very simple printing class in my application that
uses the pcl driver and prints to a HP USB printer. The printing
aspect is fine under normal circumstances, but I cannot see an obvious
way to handle error conditions such as no paper in printer etc.

I am doing something like this (general error checking and other
details removed for clarity):

// Get a DC to the printer. If printer isn't powered this will fail -
can print error stating "printer not found" or similar
hdcPrinter = CreateDC(TEXT("pcl.dll"), TEXT("Deskjet 460"), TEXT
("LPT1:"), &m_dmPrintMode);

// Set a callback to allow a "cancel" dialog
SetAbortProc( hdcPrinter, PrinterStatus)

// Signal the start of a document
StartDoc(hdcPrinter, &docInfo)
// Signal the start of a page
StartPage(hdcPrinter)

// Prepare the page to print/formatting etc

// Finished preparing the page
EndPage(hdcPrinter)

// This is the only page we are printing this time
EndDoc(hdcPrinter)

// Return the printer DC to the system as we are finished with it now.
DeleteDC(hdcPrinter);


Looking through the CE source I can see that the prnport.c [C:
\WINCE500\PUBLIC\COMMON\OAK\DRIVERS\PRINTER\PRNPORT.c] file handles
the error conditions I am trying to access but it sends the output to
a dialog through the ReportPrinterStatus() function. I don't want any
windows error dialogs - I want to handle this in my app and format the
message to match the rest of my GUI.
I can see through PB that if the printer is opened with PrinterOpen()
and I have a handle to the printer I can use DEV_IO_CONTROL calls to
get the printer status, but if I get a printer DC from pcl.dll I
believe (maybe incorrectly?) that I am a level up from there (i.e.
pcl.dll makes the calls to PrinterOpen() etc). How can I get error
messages in this case or should I forget pcl.dll and make the calls in
my app myself?

Thanks for any help you can provide,
-- keano

kean...@live.co.uk

unread,
Mar 9, 2009, 8:36:12 AM3/9/09
to

Can anybody comment on this please? Is there another approach I could
take?
Thanks,
--keano

tren...@hotmail.co.uk

unread,
Mar 27, 2009, 9:55:51 AM3/27/09
to
On Mar 9, 12:36 pm, keano...@live.co.uk wrote:
> On Mar 4, 4:27 pm, keano...@live.co.uk wrote:
>
>
>
>
>
>
>
> > Hi,
>
> > I hope someone can point me in the correct direction regarding the
> > printing problem I am having below:
>
> > Setup:
> > Win CE 5.0 with all QFEs installed to Jan '09
> > GENE 6315 board with Via Mark processor
> > Debug image with KITL enabled
>
> > >>Trying to print from a custom application.
>
> > I have written a very simple printing class in my application that
> > uses the pcl driver and prints to a HP USBprinter. The printing

> > aspect is fine under normal circumstances, but I cannot see an obvious
> > way to handle error conditions such as no paper inprinteretc.
>
> > I am doing something like this (general error checking and other
> > details removed for clarity):
>
> > // Get a DC to theprinter. Ifprinterisn't powered this will fail -
> > can print error stating "printernot found" or similar

> > hdcPrinter = CreateDC(TEXT("pcl.dll"), TEXT("Deskjet 460"), TEXT
> > ("LPT1:"), &m_dmPrintMode);
>
> > // Set a callback to allow a "cancel" dialog
> > SetAbortProc( hdcPrinter, PrinterStatus)
>
> > // Signal the start of a document
> > StartDoc(hdcPrinter, &docInfo)
> > // Signal the start of a page
> > StartPage(hdcPrinter)
>
> > // Prepare the page to print/formatting etc
>
> > // Finished preparing the page
> > EndPage(hdcPrinter)
>
> > // This is the only page we are printing this time
> > EndDoc(hdcPrinter)
>
> > // Return theprinterDC to the system as we are finished with it now.

> > DeleteDC(hdcPrinter);
>
> > Looking through the CE source I can see that the prnport.c [C:
> > \WINCE500\PUBLIC\COMMON\OAK\DRIVERS\PRINTER\PRNPORT.c] file handles
> > the error conditions I am trying to access but it sends the output to
> > a dialog through the ReportPrinterStatus() function. I don't want any
> > windows error dialogs - I want to handle this in my app and format the
> > message to match the rest of my GUI.
> > I can see through PB that if theprinteris opened with PrinterOpen()
> > and I have a handle to theprinterI can use DEV_IO_CONTROL calls to
> > get theprinterstatus, but if I get aprinterDC from pcl.dll I

> > believe (maybe incorrectly?) that I am a level up from there (i.e.
> > pcl.dll makes the calls to PrinterOpen() etc). How can I get error
> > messages in this case or should I forget pcl.dll and make the calls in
> > my app myself?
>
> > Thanks for any help you can provide,
> > -- keano
>
> Can anybody comment on this please? Is there another approach I could
> take?
> Thanks,
> --keano

I also have this problem with my application. Can anybody help please?

0 new messages