Preview Dialog - Print Cancel
Hi
In your standard Preview form, is there a way of capturing if the user
selects the Cancel Button on the Print Dialog (rather than the Print
Button)?
I have tried the ppReport1Cancel and all other events I can think of that
may be relevent but to no avail.
Thanks in advance.
Philip L Jackson
In your standard Preview form, is there a way of capturing if the user
selects the Cancel Button on the Print Dialog (rather than the Print
Button)?
I have tried the ppReport1Cancel and all other events I can think of that
may be relevent but to no avail.
Thanks in advance.
Philip L Jackson
This discussion has been closed.
Comments
Take a look at the following rbWiki article.
http://www.digital-metaphors.com/rbWiki/Output/Printer/Detecting_Whether_PrintDialog_Cancel
--
Regards,
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
Looks like a good answer, except that I cannot get either the
ppReport1PrintDialogClose or ppReport1PreviewFormClose events to fire.
The ppReport1AfterPrint event fires OK
Any ideas why these 2 events may not be occuring?
Thanks in advance
Regards
Philip L Jackson
I have also tried these events on theTutorials > Complete > II.Applications
Regards
PLJ
Are you by chance loading templates? If so, this is the reason you are
loosing your event handlers.
One option is to use RAP to keep all event handlers local to each template.
Another is to use the template events to be sure the event handlers are
assigned after the template has loaded (Template.OnLoadEnd).
--------------------------------------------
Article: Troubleshooting Lost Event Handlers
--------------------------------------------
Let's assume you have created a report in Delphi and assign an event
handlers to the OnPreviewFormCreate event of the report. The event is
generated by Delphi as:
procedure TForm1.ppReport1PreviewFormCreate(Sender: TObject);
You then save the report to an RTM file 'Report1.RTM.' The events are
stored as references only, and so the RTM contains:
object ppReport1: TppReport
.
.
OnPreviewFormCreate = ppReport1PreviewFormCreate
end
You then go on to work on a different report. Saving it with under then
name 'Report2.RTM'. Only this time, before you save the report you
change the report component name to: rptOrders. Delphi automatically
updates the event declaration for OnPreviewFormCreate event to:
procedure TForm1.rptOrdersPreviewFormCreate(Sender: TObject);
You then create two buttons on the form, one to load Report1 and
preview, the other to load Report2 and preview. When you run the app
and click Report1, you an error. This is because the Report1.RTM file
contains a reference to ppReport1PreviewFormCreate, a method which no
longer exists (at least with this name) in the form.
One answer is to load all your rtm files into the report component you
will be using for loading. Fix any errors, reassign any events that get
cleared. This will update your rtms to contain the proper event handler
names.
----------------------------------------------
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