Solved

Wait for a some process

Posted on 1999-01-07
14
173 Views
Last Modified: 2010-04-06
I am making a database access, and i want a massage box
("Please Wait")to be displayed all the time while the query is running. And it wouldn't close until the query is running.
0
Comment
Question by:danil082697
  • 4
  • 3
  • 2
  • +4
14 Comments
 
LVL 27

Expert Comment

by:kretzschmar
Comment Utility
hi danil,

make a form name it i.e. Waitform

and use this code

Waitform.show;
query1.open;
Waitform.close;

meikl
0
 
LVL 8

Expert Comment

by:ZifNab
Comment Utility
Hi,

I would prefer to use ShowModal, because danil doesn't wants that the user  can do anything else  if the query is still running. Also hide all bordericons (no cancel button available etc). set biSystemMenu to false, etc.

Although this is great, if the time is long for quering, the user can become impatient. Therefor I would suggest to place a gauge (or something like that) to indicate the progress of the query.

The beauty is that the free RXLib has such a component which can be attached to a query and can give status of the progress to a gauge or progress bar. http://rx.demo.ru.

So this we don't have to program ourselfs :-))

Regards, Zif.
0
 
LVL 8

Expert Comment

by:ZifNab
Comment Utility
forgot to mention : the component of RxLib call DBProgress (how convienient!)
0
 
LVL 20

Expert Comment

by:Madshi
Comment Utility
Hi Zif,

I don't know this DBProgress (since I don't use Databases at all). If it works: Fine. Then please forget the rest of this comment...   :-)

Your ShowModal suggestion wouldn't work, because ShowModal returns only if the form (that is shown with ShowModal) is closed.
So something like
  Waitform.showModal;
  query1.open;
  Waitform.close;
won't work. "Waitfrom.showModal" will return in that moment, where Waitform is closed.

Regards, Madshi.
0
 
LVL 8

Expert Comment

by:ZifNab
Comment Utility
Hi Madshi,

:-) Your correct, I was forgetting some things... ShowModal can't work the way I proposed.... But if we can cach the progress, we can catch the end and we can fire the on close event that way... wow, what a mistake.. .thanks for pointing me out.

so new proposal :

In form1
  Form2.ShowModal;

with in form2.activate (or another event): doQuery
with in Query-end (DBProgress?) event : close (to close form2);

Regards, Zif/
0
 
LVL 20

Expert Comment

by:Madshi
Comment Utility
That should work...  :-)
0
 
LVL 7

Expert Comment

by:ahalya
Comment Utility
wouldn't something like

if "Query is Busy" then Action := caNone;

 in the FormClose event handler be easy here ?

0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 8

Expert Comment

by:ZifNab
Comment Utility
yes ahalya, but how to know when a 'query is busy'? --> DBProgress code, my guess.
0
 

Expert Comment

by:shock_wang
Comment Utility
Hi,All
  I think you can try multithread if you like.
  For example:

.....in form1
var
  aThread: TThreadQuery;
  bThread: TThreadForm;

procedure TForm1.Button1Click(Sender: TObject);
begin
  aThread:= TThreadQuery.Create(False);
  bThread:= TThreadShowForm.Create(False);
  ......
end;

....in unit2

procedure TThreadQuery.Execute;
begin
  { Place thread code here }
    .....  
  form1.bThread.Terminate;
  form1.bThread.Suspend;
  form1.bThread.Free;
end;

.....in unit3

procedure TThreadShowForm.Execute;
begin
  { Place thread code here }
 
  Form2:= TForm2.Create(self);
  Form2.ShowModal;

  .....  
end;

procedure TThreadShowForm.Terminate;
begin
  { Place thread code here }
  TForm2.Close;
  TForm2.Free;
 
  .....  
end;


 But it looks too trouble!!!
 HaHa!

Regards,
Shock

0
 

Expert Comment

by:shock_wang
Comment Utility
It should be:

procedure TThreadShowForm.Terminate;
begin
  { Place thread code here }
  Form2.Close;
  Form2.Free;
   
  .....  
end;

0
 

Expert Comment

by:shock_wang
Comment Utility
form2 and unit2 are different units
0
 
LVL 1

Accepted Solution

by:
adeng earned 100 total points
Comment Utility
1. Make new form for Wait Progress Event and set BorderIcon property with no SystemMenu, Minimize, etc. to prevent user close this window before process finish.
2. Set FormStyle property to fsStayOnTop
3. Set your main form enabled  property to false, to prevent user access to form.
4. write this code :

procedure TForm1.Button1Click(Sender: TObject);
begin
     try
        Enabled := False;
        frmWaitProgress.Show; // it's not a modal dialog !!
        query1.open;
        .....
        .....
     finally            // use try .. finally for safe
            frmWaitProgress.Close;
            Enabled := True;
     end;
end;

Hope this usefull

Adeng.
0
 
LVL 27

Expert Comment

by:kretzschmar
Comment Utility
hi friends,

simple questions become complex answers.

a other idea

while not play animation while waiting

something like

createprocess(someparameters); {i.e start mediaplayer and show a movie}
query1.open;
terminateprocess(someparameters);

meikl
0
 
LVL 1

Author Comment

by:danil082697
Comment Utility
thanks guys
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now