![]() |
|
#1
|
|||
|
|||
|
I am writing a problem, which envolves A LOT of heavy database work. One part requires the program to get data from the form, and link it with records in a VERY large database and display matches on the form. Currently I have this code in the Form.Show procedure, but TAKES SO LONG the program appears to have hung up.
My question is, is there a way of getting code to be executed once the form is ACTUALLY visible, so the user can see that it is doing what it is supposed 2 be doing. Thanks in Advance, Sid |
|
#2
|
|||
|
|||
|
i don't know if this is what u want but on the forms on active property put
if form1.visible=true then begin; ... ... end; i hope that helps James Sturrock |
|
#3
|
|||
|
|||
|
Move your code from the OnShow event to the OnActivate event. Be careful, though, because the OnActivate event will fire every time that form activates. The form will deactivate if you display a non-modal form and will re-activate once the original form regains focus, thus firing the OnActivate event. If you fire the OnActivate event while in your database processing, I imagine it wouldn't be too good
. A quick fix for this is to create a public boolean that is toggled (true) when you initially start the database manipulation, and then toggled (false) once completed.Hope this helps! Scottg |
|
#4
|
|||
|
|||
|
Oh yeah...almost forgot! Make sure you use Application.ProcessMessages throughout your database code so that the application does not look like it is ("Not Responding") to the Win9x task manager.
Scottg |
|
#5
|
|||
|
|||
|
You could also add a TTimer component to the form, that gets enabled by .Show event and fires after any preset interval. The OnTimer event could then get things rolling.
A second thread may be better, to allow user to use the screen while the database access occurs in the background. |
![]() |
| Thread Tools | |
| Display Modes | |
|
|