Creating "TppReport" objects as required
RB 10.07 Delphi 7
Hello
My reporting program needs to be able to show multiple reports simultaiously
so I create "TppReport" objects as required. I set the "ModalPreview"
property to false and everything appears to work fine.
My concern is that the object isn't being freed correctly when the user
closes the dialog. Is there anyway I can hook into an "OnClose" type event
to ensure everything is closed and freed. I tried connecting to the
"OnPreviewFormClose" event but it didn't fire when I closed the dialog. Here
is a code snippet of my creation process:
theCtrl := TppReport.Create (nil) ;
theCtrl.OnPreviewFormClose := ThePrintDialogClose ; <-- my event handler
that doesn't get called
theCtrl.ModalCancelDialog := false ;
theCtrl.ModalPreview := false ;
On a side issue, if I create the above object but pass in a reference to the
caller (eg Self), the objects seem to interfere with each other. Say I run
the same report twice, the first appears correct but the second will show
all the times as being the same and the time is the time I ran the first
report ! Obviously both reports should appear identical. As already stated,
if I use "nil" instead of "Self" they work fine.
Am I doing something wrong ?
Ian
Hello
My reporting program needs to be able to show multiple reports simultaiously
so I create "TppReport" objects as required. I set the "ModalPreview"
property to false and everything appears to work fine.
My concern is that the object isn't being freed correctly when the user
closes the dialog. Is there anyway I can hook into an "OnClose" type event
to ensure everything is closed and freed. I tried connecting to the
"OnPreviewFormClose" event but it didn't fire when I closed the dialog. Here
is a code snippet of my creation process:
theCtrl := TppReport.Create (nil) ;
theCtrl.OnPreviewFormClose := ThePrintDialogClose ; <-- my event handler
that doesn't get called
theCtrl.ModalCancelDialog := false ;
theCtrl.ModalPreview := false ;
On a side issue, if I create the above object but pass in a reference to the
caller (eg Self), the objects seem to interfere with each other. Say I run
the same report twice, the first appears correct but the second will show
all the times as being the same and the time is the time I ran the first
report ! Obviously both reports should appear identical. As already stated,
if I use "nil" instead of "Self" they work fine.
Am I doing something wrong ?
Ian
This discussion has been closed.
Comments
The following should free everything:
theCtrl := TppREport.Create();
try
...
theCtrl.Print;
finally
theCtrl.Free;
end;
show it
I guess I'll need to hold a reference of each in a list but I'd like a call
back so I know when to remove it from the list.
Ian
Using your exact code below, the OnPreviewFormClose event fired as expected.
I noticed that the name of your event is "ThePrintDialogClose"... do you
perhaps want to implement the OnPrintDialogClose event instead?
Note that you will not be able to free the report object directly from the
OnPreviewFormClose event as it fires while the report is still closing. One
option is to create a TTimer and use its event to free the report.
--
Regards,
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
event. If I set it after I created the control it didn't get set (or was
overwritten by a nil). I guess the "OnPreviewFormClose" event works when you
drop the control on a form and set the event, but doing it all
programmatically I need to wait for the control to build up its different
elements first.
I'm a bit unclear about what is happening. As I mentioned in my previous
post, I copied your code exactly to the OnClick of a button and the event
fired correctly. I did not drop a report on a form.
--
Regards,
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com