Printing without showing dialog
Hi,
I've got an unusual problem, and I can't figure out the solution.
When I try to print a report, it brings up a dialog box first (asking which
printer to print to) before printing the actual document. I have set:
devicetype = printer
showprintdialog = false
But it still persists on showing the printer dialog when printing.
I can't figure out what I've missed. Is there another setting I have missed?
Thanks & Regards
Adam.
I've got an unusual problem, and I can't figure out the solution.
When I try to print a report, it brings up a dialog box first (asking which
printer to print to) before printing the actual document. I have set:
devicetype = printer
showprintdialog = false
But it still persists on showing the printer dialog when printing.
I can't figure out what I've missed. Is there another setting I have missed?
Thanks & Regards
Adam.
This discussion has been closed.
Comments
Are you loading templates? If so, the settings defined when the template
was saved will overwrite the settings you set for the TppReport object once
it is loaded. You will either need to set the ShowPrinterDialog property in
a template event such as the OnLoadEnd or resave the template with the
proper settings.
----------------------------------------------
Tech Tip: Using Template Events
----------------------------------------------
The Report.Template object has several events that can be used for
customizing what happens when a report is loaded or saved:
- OnLoadStart
- OnLoadEnd
- OnNew
- OnSaveStart
- OnSaveEnd
The OnLoadEnd and OnNew events are often used to perform actions related
to report and data initialization.
The OnSaveEnd event is often used to save additional descriptive
("meta") data to the database each time the report is saved.
Example:
The Report.Template events are public and therefore must be assigned at
run-time.
1. In the private section of your form declaration you can declare an
event-handler method:
TForm = class(TForm)
private
procedure myTemplateOnLoadEndEvent(Sender: TObject);
public
end;
2. In the Form.OnCreate event, you can assign the event-handler to the
event:
procedure TForm1.FormCreate(Sender: TObject);
begin
ppReport1.Template.OnLoadEnd := myTemplateOnLoadEndEvent;
end;
3. Implement the event-handler method:
procedure TForm1.myTemplateOnLoadEndEvent(Sender: TObject);
begin
{add code here to initial the report or data, etc. }
ppReport1.PrinterSetup.MarginTop := 0.5;
end;
--
Regards,
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
Thanks for your reply.
I was loading templates, but it was just for the header. I tried what you
suggested, but it made no difference.
Thinking I may have not followed the instructions correctly, I decided to
remove the template from that report entirely, but it still persists in
showing the print dialog.
Do you have any other ideas?
Thanks & Regards
Adam.
Please create a minimal example of this behavior (i.e. empty report on a
form with a button) and send it to support@digital-metaphors.com in .zip
format and we'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