Hi,
is it possible to execute a crystal report (TCrpe component) from a Delphi non VCL main thread when Output = toWindow?
- I execute reports from a background thread, and when Output is toPrinter or toExport, everything is fine.
- I know that creating forms in a Delphi non VCL main thread generally is a bad idea.
- When a Crystal Report is executed, and Output=toWindow, the component creates the output window on its own. So I cannot prevent that the window is created by the background thread.
- So is there a clean way to execute the report in a background thread, and display the result in a cleanly created form?
- Version: Crystal11VCL7
The following code does not work:
procedure TMyThread.Execute;
var
cr: TCrpe;
begin
inherited;
cr:= TCrpe.Create(nil);
cr.ReportName:= 'C:\TestReport.rpt';
cr.Output:= toWindow;
cr.WindowParent:= Form1; //This is the main form
cr.Execute;
end;
- It seems like the report will be created and immediately destroyed afterwards.
- When I enter a message loop right after cr.Execute (
while true do Application.ProcessMessages;
- which is obviously a very bad idea), the report window is shown nicely.
Any idea, how to do it right? Or is it simply not possible? Thanks!