?
Solved

Wait for a some process

Posted on 1999-01-07
14
Medium Priority
?
186 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

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

Technology Partners: 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

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses
Course of the Month11 days, 3 hours left to enroll

770 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