Re:Repainting current form during a lengthy query??
Because you crossposted this in so many groups, I'm allmost sure you'll miss
it, but anyway:
Open your query in separate thread. If you open it in main thread, it
freezes until the query executes.
TQueryThread=class(TThread)
Query : TQuery;
Owner:TSomeForm;
constructor Create(AOwner:TSomeForm;AQuery:TQuery);
procedure Execute; override;
end;
constructor TQueryThread.Create(AOwner:TSomeForm;AQuery:TQuery);
begin
Query := AQuery;
Owner := AOwner;
inherited Create(false);
end;
procedure TQueryThread.Execute;
begin
try
Query.Open;
except
on E:Exception do begin
Owner.ThreadException := E;
Synchronize(Owner.HandleException);
end;
end;
end;
Note that you ALLWAYS have to trap exceptions in threads.
Instead of calling AQuery.Open directly, you create the thread to open it:
T := TQueryThread.Create(Self,AQuery);
--
----------------------
Regards
Robert Cerny
Remove both qwe when replying
email: robert.qwe.ce...@neosys.xrs.qwe.si
No questions via email, unless explicitly invited.
Quote
Peak Technologies wrote in message <36d6fd8...@news.digicon.net>...
>Can anyone fill me in on how to "repaint" a form during a lengthy query?
>Sometimes a query takes 20-30 seconds to run, and if I click to another
>program on my taskbar then back, the entire Delphi application screen
>appears white. No controls are there until the query finishes, then the
>form repaints itself.
>Have I coded something wrong? This has always been a problem with my
Delphi
>apps I just haven't found the answer yet.
>--Eric
>Peak Technologies