Delphi Pages Forums  

Go Back   Delphi Pages Forums > Delphi Forum > General

Lost Password?

Reply
 
Thread Tools Display Modes
  #1  
Old 02-05-2001, 09:47 AM
Sid Sid is offline
Junior Member
 
Join Date: Jan 2001
Posts: 12
Default Running Code once form is visible

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
Reply With Quote
  #2  
Old 02-05-2001, 10:51 AM
jamessturrock jamessturrock is offline
Senior Member
 
Join Date: Jan 2001
Posts: 170
Default RE: Running Code once form is visible

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
Reply With Quote
  #3  
Old 02-07-2001, 06:09 AM
Scottg Scottg is offline
Senior Member
 
Join Date: Feb 2001
Posts: 109
Default RE: Running Code once form is visible

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
Reply With Quote
  #4  
Old 02-07-2001, 06:10 AM
Scottg Scottg is offline
Senior Member
 
Join Date: Feb 2001
Posts: 109
Default RE: RE: Running Code once form is visible

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
Reply With Quote
  #5  
Old 02-08-2001, 08:35 PM
bob moran bob moran is offline
Junior Member
 
Join Date: Feb 2001
Posts: 3
Default RE: Running Code once form is visible

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.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT. The time now is 03:48 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2013, vBulletin Solutions, Inc.