When I print a document from my Delphi 2007 program I quite often get a message "Printing in progress " and printing is aborted. Only part of the page is printed,not always identical part,but close.
When closing the message I get "Access violation at address 004FEEC5 in module........read of address 00000008."
I then have to exit and restart the program to start a new print session, or I will get the same message.

I can't see a pattern, but have got an impression that it has something to do with how busy the computer is.

Any ideas how to control this problem?

I'm soon getting desperate.
I have tried and tried and tried to answer the response I got on my article, but every time I try, and click "Reply to this Article" it seems like I'm logged out and I'm adviced to be a member, despite I'm logged in already.
What is wrong?? Noone to get advice from either.
Now I had to register as a new member to magage to give this response.

Reply to pritaeas:

Yes,
I have tried with different PDF printers on different computers, Vista and Win 7.

Can you share part of your code. If it fails on all, it has to be a coding issue.

As for the logging in, does it happen with every browser? You can consider posting a report in the Community Feedback forum.

  Printer.Orientation := poPortrait;
  Printer.Title := txt + ' SS' + FrmNotes.EdStageNo.text + ' Page ' + pagesToPrint;
  if Form1.ActivateDelayAtPrintout.Checked then
  begin
    showmessage('Delay 1');  //Pause to avoid "Printing in progress" error
    Form1.LblWAIT.update;
  end;
  printer.beginDoc;
  if Form1.ActivateDelayAtPrintout.Checked then
  begin
    showmessage('Delay 2');  // Pause to avoid "Printing in progress" error
                             // Not sure if this second delay is needed
    Form1.LblWAIT.update;
  end;

I have put in those delays, because if I wait for some seconds it works.
If I just loop for some seconds I get the error.
It has never happened when I run RAD Studio, only with compiled programs.

My title is not empty.
The problem doesn't happen every time. If I repeat printing, or choose a different PDF printer it may work sometimes.

It has never happened when I run RAD Studio, only with compiled programs.

I missed this. Does it make a difference whether it is a Debug or Release build ?

No difference.
Hope my images of my error messages are attached now.

btw: I'm using Firefox now to avoid being logged out.

But it never happens when I run it from RAD Studio

When it happen it seems to happen on the "RoundRect" below as "PrintHeadOfPage 1.5" is shown on screen, and I get the rectangle drawn on my PDF document.
However I think I have got the error in at least one other position some time, with more of the printout done.
Where can I find out what "Printing in progress" actually means?

Form1.LblWAIT.Caption := 'PrintHeadOfPage 1.5';
Form1.LblWAIT.update;
  printer.canvas.RoundRect(posX('Left border', printer.pagewidth)
                       , posY('Top border', printer.PageHeight, pageNo)
                       , posX('Right border', printer.pagewidth)
                       , posY('Head bottom border', printer.PageHeight, pageNo)
                       , i, i);
Form1.LblWAIT.Caption := 'PrintHeadOfPage 2';

Can you add exception handling around the printing, perhaps there's a hidden crash somewhere that triggers that message.

When it happen it seems to happen on the "RoundRect" below as "PrintHeadOfPage 1.5" is shown on screen, and I get the rectangle drawn on my PDF document.
However I think I have got the error in at least one other position some time, with more of the printout done.
Where can I find out what "Printing in progress" actually means?

Form1.LblWAIT.Caption := 'PrintHeadOfPage 1.5';
Form1.LblWAIT.update;
  printer.canvas.RoundRect(posX('Left border', printer.pagewidth)
                       , posY('Top border', printer.PageHeight, pageNo)
                       , posX('Right border', printer.pagewidth)
                       , posY('Head bottom border', printer.PageHeight, pageNo)
                       , i, i);
Form1.LblWAIT.Caption := 'PrintHeadOfPage 2';

With try - except I have located the problem to my next RoundRect sentence. Is there a way to get deeper info about the error?

Form1.LblWAIT.Caption := 'PrintHeadOfPage 2';
try

   printer.canvas.RoundRect(posX('Left border', printer.pagewidth)
                       , posY('Notes top border', printer.PageHeight, pageNo)
                       , posX('Right border', printer.pagewidth)
                       , posY('Bottom border', printer.PageHeight, pageNo)
                       , i, i);
except
  showmessage('Error at printing border ');
end;
Form1.LblWAIT.Caption := 'PrintHeadOfPage 2';
try
  printer.canvas.RoundRect(posX('Left border', printer.pagewidth)
                   , posY('Notes top border', printer.PageHeight, pageNo)
                   , posX('Right border', printer.pagewidth)
                   , posY('Bottom border', printer.PageHeight, pageNo)
                   , i, i);
except
  on E: Exception do
    ShowMessage(E.Message);
end;

You are a star!
However I can't find a way to convert the given addresses 00520D35 and 00000008 to my source code. I think I have searched everywhere, but probably not.

You can try to check if the printer, or any of the properties are unavailable. Or perhaps it is in the PosX or PosY functions.

I'm suspecting something is reentrant. Will search along that path....

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.