Solved

Delay in Borland c++ for windows

Posted on 1998-03-17
6
544 Views
Last Modified: 2008-02-01
How can i do a delay on a windows platform in Bcw?
in c++ i used delay, but it doesnt work in windows platform.

and there is another problem with my c++ for windows.
I just got it a few days, and for some reason whenever I try to run a project, from the example or another place, it makes it and then it says: could not create process

?! whats wrong ?!
thanx.. Yoli
0
Comment
Question by:yolis
  • 4
6 Comments
 
LVL 22

Expert Comment

by:nietod
ID: 1183566
If by delay you mean suspend execution of your program, you can use the Sleep() windiows API function.
0
 
LVL 22

Expert Comment

by:nietod
ID: 1183567
You specify a parameter to sleep that indicates how long you want to suspend execution in milliseconds.  Specify Sleep(500) to suspend for 1/2 second.  Sleep(1000) to suspend for a second, etc.

Can you provide more details about your make error?
0
 

Author Comment

by:yolis
ID: 1183568
thanx for the answer about the delay!
about my make problem, the problem with it that it doesnt give mt anymore details.
all that it says once it finshed making it, is: could not create process, even that the make was succesful...

0
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 
LVL 22

Expert Comment

by:nietod
ID: 1183569
Since it is new you can call Borland's instalation support and tell themn you think it is not installed correctly.
0
 

Accepted Solution

by:
Ant031898 earned 50 total points
ID: 1183570
Is is not a good idea to have delays in Windows code, but if you have to do it, this is one way:
you can write a function called delay:

void Delay(int delay){  //delay = time in seconds
 long time = GetTickCount();
 MSG msg;
 int quit = 0;
 while (!quit){
    if (GetMessage(&msg, HWindow, 0, 0)) {
      long timemsg = msg.time;
      TranslateMessage(&msg);
      DispatchMessage(&msg);
      if ( (timemsg - time) >= (1000*dealy) )
          quit=1;
   }
 }
}
0
 
LVL 22

Expert Comment

by:nietod
ID: 1183571
Except that does not hold up execution of a program.  (It prevents a section of code from continuing, but not the entire program.)  If you need to stop the execution of the program for a while, waiting for a hardware device, say.  That won't work as your program will still get and process messages.  The sleep function will suspend the execution of your program, but allow other programs to continue.
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

In days of old, returning something by value from a function in C++ was necessarily avoided because it would, invariably, involve one or even two copies of the object being created and potentially costly calls to a copy-constructor and destructor. A…
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

828 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