Solved

How to make an app wait...

Posted on 1998-04-23
6
139 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
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 
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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

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…
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…
This video discusses moving either the default database or any database to a new volume.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

744 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