Solved

Wait for a some process

Posted on 1999-01-07
14
180 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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
 
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

733 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