"Damien Long" <[EMAIL PROTECTED]> wrote on 01/05/2001
10:38:18:
>
>Nello,
> What I am trying to achieve is to run more than one report at a time
>in a small app. But at the momment only one report can be shown and
>run.
> Thats where the modal problem comes in. So how would i go about
> showing the modal
>form on a seperate thread?
All you need to do is create a TThread descendant that creates a new
instance of the report form, loads the appropriate data, then displays
the form. Of course it's never quite that simple, but that's the gist
of it.
Below I've put some sample code that might give you some ideas. It's a
rough translation from C++, so excuse any blatant errors, and I
stripped out all the list handling for brevity. Basically you'll
need to make sure all of these threads reacts properly to being killed
otherwise your application may never shutdown while there's a report
window active, etc. If you keep a list of threads then you can post a
close message to their windows and wait for the thread to terminate,
etc.
TReportThread = class(TThread)
protected
procedure Execute; override;
public
constructor Create;
destructor Destroy; override;
rptForm: TReportForm;
end;
constructor TReportThread.Create;
begin
rptForm := TReportForm.Create(Application);
inherited Create(true);
end;
destructor TReportThread.Destroy;
begin
rptForm.Free;
inherited Destroy;
end;
procedure TReportThread.Execute;
begin
rptForm.ShowModal;
end;
procedure ShowReport(rptData: TReportData)
var
rptThd: TReportThread;
begin
rptThd := TReportThread.Create();
{ add it to a TThreadList or something so it can be killed later }
{ setup the report }
...
{ now show it }
rptThd.Resume;
end;
--
Corey Murtagh
The Electric Monk
"Quidquid latine dictum sit, altum viditur!"
---------------------------------------------------------------------------
New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
Website: http://www.delphi.org.nz
To UnSub, send email to: [EMAIL PROTECTED]
with body of "unsubscribe delphi"