Solved

How to make an app wait...

Posted on 1998-04-23
6
140 Views
Last Modified: 2010-04-06
Hi,
 The app I'm writing runs DVIPS (as you probably know it converts device independant files to postscript files) externally if the user clicks the relevant button. This is fine, but I want to display a messagebox saying whether the file was created successfully or not. I've written some code if FileExists ..... then .. etc. The problem is that I need the app to wait a few seconds before it checks whether the file has been created. Can anyone tell me how to do this?
A quick response would be much appreciated...
Cheers.
0
Comment
Question by:PiersBull
  • 4
  • 2
6 Comments
 
LVL 5

Accepted Solution

by:
inter earned 50 total points
ID: 1336639
Hi there,
For Delphi 2.0+ use API function
   ...
   Sleep(2000); //wait for 2 seconds
   ...
Regards, (if I interpret the problem wrong, please write down)
Igor
0
 

Author Comment

by:PiersBull
ID: 1336640
Hi inter,
   unfortunately I'm only on Delphi 1. Any ideas?
Cheers.
0
 
LVL 5

Expert Comment

by:inter
ID: 1336641
The basic solution I can found for Delphi 1.0 is  as follows:

1 - Declare a global var in your form as
var
  TimeOut : boolean;
2 - Put a timer on your form
3 - In FormCreate;
  Timer1.Enabled := false;
  TimeOut := false;
4 - Add the following procedure to your unit(form object)
procedure TForm1.Wait(Msec : integer);
begin
   Timer1.Interval := Msec;
   TimeOut := false;
   while not (TimeOut) and not (Application.Terminated) do
       Application.ProcessMessages;
end;
5 - in OnTimer event of Timer1
begin
  TimeOut := true;
  Timer1.Enabled := false;
end;
6 - Now you can call from any where as follows:
// do you operations
....
Wait(1000); //wait one second(approximate for Win16)
//check them
...

Regards,
Igor
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 5

Expert Comment

by:inter
ID: 1336642
Yeah I have found it:

Write and call this proc instead(in WinProcs)

procedure Wait(Msec : longint);
var
  b : longint;
begin
  b := GetTickCount;
  while (GetTickCount - b) < Msec do
     Application.ProcessMessages;
end;

regards
igor
0
 
LVL 5

Expert Comment

by:inter
ID: 1336643
I means GetTickCount is in WinProcs
0
 

Author Comment

by:PiersBull
ID: 1336644
Did the job nicely! Cheers Igor.
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

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
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 Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

895 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

12 Experts available now in Live!

Get 1:1 Help Now