[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Wait for a some process

Posted on 1999-01-07
14
Medium Priority
?
188 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
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…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Suggested Courses

656 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