Solved

Wait for a some process

Posted on 1999-01-07
14
174 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
ID: 1355150
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
ID: 1355151
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
ID: 1355152
forgot to mention : the component of RxLib call DBProgress (how convienient!)
0
 
LVL 20

Expert Comment

by:Madshi
ID: 1355153
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
ID: 1355154
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
ID: 1355155
That should work...  :-)
0
 
LVL 7

Expert Comment

by:ahalya
ID: 1355156
wouldn't something like

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

 in the FormClose event handler be easy here ?

0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 8

Expert Comment

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

Expert Comment

by:shock_wang
ID: 1355158
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
ID: 1355159
It should be:

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

0
 

Expert Comment

by:shock_wang
ID: 1355160
form2 and unit2 are different units
0
 
LVL 1

Accepted Solution

by:
adeng earned 100 total points
ID: 1355161
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
ID: 1355162
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
ID: 1355163
thanks guys
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Sending Gmail through Delphi 3 90
Delphi XE2 application frozen on Windows 10 10 266
Reconfigure Delphi Install? 2 45
Firemonkey DbLookupComboBox equivalent ? 2 32
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…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
Concerto provides fully managed cloud services and the expertise to provide an easy and reliable route to the cloud. Our best-in-class solutions help you address the toughest IT challenges, find new efficiencies and deliver the best application expe…

932 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