Watch, Follow, &
Connect with Us
Public Report
Report From: Delphi-BCB/VCL/Printing    [ Add a report in this area ]  
Report #:  2965   Status: Closed
Bug in Printers.pas - After aborting a job, next jobs not printable
Project:  Delphi Build #:  6.163
Version:    10.0 Submitted By:   Oliver Kunz
Report Type:  Basic functionality failure Date Reported:  11/21/2002 5:49:26 AM
Severity:    Commonly encountered problem Last Updated: 3/20/2012 2:24:39 AM
Platform:    All versions Internal Tracking #:   235733
Resolution: Need More Info (Resolution Comments) Resolved in Build: : 10.0.2288.42451
Duplicate of:  None
Voting and Rating
Overall Rating: (1 Total Rating)
4.00 out of 5
Total Votes: None
Description
No documents will be printed anymore after a Printer.BeginDoc; ...  Printer.Abort; - calling sequence.
Steps to Reproduce:
If you are printing with the functions
Printer.BeginDoc; <something2print> Printer.EndDoc;  the printouts are correct.

If you have to abort a print job like
Printer.BeginDoc; <something2print> Printer.Abort; the printout is aborted - ok so far.

But if you then like to print something else with
Printer.BeginDoc; <something2print> Printer.EndDoc;  these documents are not printed until you restart your application.



Workarounds
(->The COMMENTS-Section of the Quality Central Windows Client does not work)

If the document has been aborted in Windows with the AbortDoc()-function it seems that windows did not allow to use the DC again for next printouts, resp. all data sent to this DC will be discarded.
The workaround is to delete the DC after an abort, so for the next document to print, a new DC is generated automatically.

See the two changed functions of the unit Printers in the following:


procedure TPrinter.Abort;
begin
//CheckPrinting(True);            obsolete:  will be called in the EndDoc function below
//AbortDoc(Canvas.Handle);   in this place the function always results with an
//                                             SP_ERROR errcor code, because EndPage() was
//                                             not called before
  FAborted := True;
  EndDoc;
end;

procedure TPrinter.EndDoc;
begin
  CheckPrinting(True);
  EndPage(DC);
  if not Aborted then Windows.EndDoc(DC);
  FPrinting := False;
  if Aborted then begin          //inserted
    AbortDoc(DC);                  //inserted  here AbortDoc is right
    SetState(psNoHandle);     //inserted  now release DC
  end;                                    //inserted
  FAborted := False;
  FPageNumber := 0;
end;


Now it works fine.

---------

(->The COMMENTS-Section of the Quality Central Windows Client does not work)

If the document has been aborted in Windows with the AbortDoc()-function it seems that windows did not allow to use the DC again for next printouts, resp. all data sent to this DC will be discarded.
The workaround is to delete the DC after an abort, so for the next document to print, a new DC is generated automatically.

See the two changed functions of the unit Printers in the following:


procedure TPrinter.Abort;
begin
//CheckPrinting(True);            obsolete:  will be called in the EndDoc function below
//AbortDoc(Canvas.Handle);   in this place the function always results with an
//                                             SP_ERROR errcor code, because EndPage() was
//                                             not called before
  FAborted := True;
  EndDoc;
end;

procedure TPrinter.EndDoc;
begin
  CheckPrinting(True);
  EndPage(DC);
  if not Aborted then Windows.EndDoc(DC);
  FPrinting := False;
  if Aborted then begin          //inserted
    AbortDoc(DC);                  //inserted  here AbortDoc is right
    SetState(psNoHandle);     //inserted  now release DC
  end;                                    //inserted
  FAborted := False;
  FPageNumber := 0;
end;


Now it works fine.

---------

(->The COMMENTS-Section of the Quality Central Windows Client does not work)

If the document has been aborted in Windows with the AbortDoc()-function it seems that windows did not allow to use the DC again for next printouts, resp. all data sent to this DC will be discarded.
The workaround is to delete the DC after an abort, so for the next document to print, a new DC is generated automatically.

See the two changed functions of the unit Printers in the following:


procedure TPrinter.Abort;
begin
//CheckPrinting(True);            obsolete:  will be called in the EndDoc function below
//AbortDoc(Canvas.Handle);   in this place the function always results with an
//                                             SP_ERROR errcor code, because EndPage() was
//                                             not called before
  FAborted := True;
  EndDoc;
end;

procedure TPrinter.EndDoc;
begin
  CheckPrinting(True);
  EndPage(DC);
  if not Aborted then Windows.EndDoc(DC);
  FPrinting := False;
  if Aborted then begin          //inserted
    AbortDoc(DC);                  //inserted  here AbortDoc is right
    SetState(psNoHandle);     //inserted  now release DC
  end;                                    //inserted
  FAborted := False;
  FPageNumber := 0;
end;


Now it works fine.
Attachment
None
Comments

Rod Rishworth at 11/22/2002 12:20:05 AM -
Two unprocessed workarounds yet I can comment...

Server Response from: ETNACODE01