Backgroud:
I'm now trying to print via GDI Print API, and it looks like this:
StartDoc(hDC,&docinfo)
foreach page in page_buf
StartPage(hDC)
/* write the page to printer DC */
EndPage(hDC)
EndDoc(hDC)
The Problem:
During printing there would be a notification area icon, and by clicking on it there would be a small window showing current printing jobs on a specified printer.
By right-clicking on a printing job and choosing Cancel
, a printing job shall be cancelled. But my application continues sending data to the printer DC until all pages are processed, and the status keeps showing Deleting - Spooling
before it finishes.
What I want is to stop the printing procedure right after choosing to cancel it.
What I've tried:
1. First I thought the device content would get invalid after cancelling the job (that's of course not true), and tried to examine the return values of StartPage
and EndPage
. Then I found they both don't fail after the cancellation of printing job.
2. I've also tried SetAbortProc
and DocumentEvent
, and found they're not what I want.
But I suppose there shall be some mechanism to indicate my application when the printing job is cancelled. It would be appreciated if someone tries to help.