Problem when printing to archive
Hi,
I have a problem when printing to an ArchiveFile when the PassSetting is set
to TwoPass. As a brief overview my TppReport is set to print to the Screen
then when the user clicks the Print button it calls the overridden print
method from my custom preview which does the following:
procedure TTestPreview.Print;
begin
Report.DeviceType := 'ArchiveFile';
Report.ArchiveFileName := 'C:\MyTest.tst';
Report.ShowPrintDialog := False;
Report.Print;
end;
If the preview form has fully completed generating all the pages ie
successfully completed 2 passes then everything works fine and the
ArchiveFile is created without the print dialog being displayed. However, if
the preview form has not completed the 2 passes and I click the print button
then I am presented with the print dialog which is not what I want to
happen. Any ideas???
I have a problem when printing to an ArchiveFile when the PassSetting is set
to TwoPass. As a brief overview my TppReport is set to print to the Screen
then when the user clicks the Print button it calls the overridden print
method from my custom preview which does the following:
procedure TTestPreview.Print;
begin
Report.DeviceType := 'ArchiveFile';
Report.ArchiveFileName := 'C:\MyTest.tst';
Report.ShowPrintDialog := False;
Report.Print;
end;
If the preview form has fully completed generating all the pages ie
successfully completed 2 passes then everything works fine and the
ArchiveFile is created without the print dialog being displayed. However, if
the preview form has not completed the 2 passes and I click the print button
then I am presented with the print dialog which is not what I want to
happen. Any ideas???
This discussion has been closed.
Comments
When you print without finishing the second pass, is the code you posted
below actually being executed? Try placing some stops in your custom
preview code to find out why the print dialog is being displayed.
--
Regards,
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
Yes all the code is being executed when it gets to the Print method the
Print Dialog is displayed? Could there be anyway of only enabling the print
button onces the 2nd pass has completed???
Cheers
Pete
I'm a bit unclear about what is happening here. After the line of code
"Report.ShowPrintDialog = False" is executed, the print dialog still shows
up? There has to be a place where this is getting set back to true. Are
you loading templates by chance?
--
Regards,
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
I am not using any templates at all, this is a very strange one. I can
attach the source code if you wish to have a look at it closer?
Cheers
Pete
Please send a small example that I can run on my machine in .zip format to
support@digital-metaphors.com and I'll take a look at it for you.
--
Regards,
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
I think I have found the problem, before the ShowPrintDialog is being set it
checks to see if the report is still printing (looks at the Printing
property), if it is still being printed then the ShowPrintDialog is not set,
so in my example it keeps the value it was originally set to which was True.
If I set this to False on the form designer the print dialog is not
displayed it just errors saying the it could not open the file.
I am going to put a check in my program to see if the report is still being
printed, if so then display a message to the user.
Thanks for your help.
Cheers
Pete
Excellent find! Glad you got it working.
--
Regards,
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com