?
Solved

Stopwatch Function in C++

Posted on 2003-03-05
7
Medium Priority
?
480 Views
Last Modified: 2012-06-27
I am fairly new to C++ but I am attempting to write a time tracking program. THIS IS NOT HOMEWORK....  The concept is that I have a GUI with 10 tasks.  For each task there is a button that is to be used to start/stop time tracking for that particular task.  When the button is pressed initially the edit field for that task will start at 00:00:00 and show a running timer for that task to show the elapsed time for the task.  When the button is pressed again I will write the value to the registry and that will be used as the start time for that task.  I have tried everything that I could think of.  Is there a function that provides this capability?  Please help.  I have spent HOURS trying to figure this out.

Brent
0
Comment
Question by:bblevins
[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
  • 3
  • 2
7 Comments
 

Expert Comment

by:mimounette
ID: 8075846

Is there a function that provides this capability?

Capability of what ? The whole solution or an api for writting in registry.
0
 

Author Comment

by:bblevins
ID: 8079773
I know how to write and retrieve values from the registry. It is the stopwatch function that I have been unable to figure out.  Sorry I wasn't more clear.
0
 

Expert Comment

by:mimounette
ID: 8082338
To be sure, you want to initialize the clock when a user click on a button and stop it (write the result in registry) when the user hits one more time the button ?

When you said C++ do you mean Visual C++ ?

If it's that I will give you my answer.


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.

 

Author Comment

by:bblevins
ID: 8082963
I am using Borland C++ Builder.  So it is just C++ not VC++

When the user clicks a button I want the clock to be initialized at 00:00:00.  If they press the button again, the clock should stop and the value written to the registry.  If the button is pressed a third time,  The clock should use the value previously written to the registry as the initialization value and continue to track time from that point.
0
 

Accepted Solution

by:
mimounette earned 200 total points
ID: 8083156
Use a global variable that will take 3 different values

enum
{
 CLOCK_NOT_INITIALIZED = 0;
 CLOCK_INITIALIZED = 1;
 CLOCK_RUNNING = 2;
 CLOCK_STOPPED = 3;
};


Constructor:
int m_nTask0Status = CLOCK_NOT_INITIALIZED;

OnClick methode

switch(m_nTask0Status)
{
 case CLOCK_NOT_INITIALIZED:
    nTask0Status = CLOCK_INITIALIZED;
    RestetTimerTask();
    break;  

 case CLOCK_RUNNING:
    nTask0Status = CLOCK_STOPPED;
    StopTimerTask();
    WriteToRegistry(GetTimerValue());
    break;  

 case CLOCK_STOPPED:
    nTask0Status = CLOCK_RUNNIN;
    SetTimerValue(ReadFromRegsitry());
    break;  

 default:
   break;
}
0
 

Expert Comment

by:CleanupPing
ID: 9447343
bblevins:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
EXPERTS:
Post your closing recommendations!  No comment means you don't care.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

In this post we will learn different types of Android Layout and some basics of an Android App.
Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
Simple Linear Regression
Six Sigma Control Plans

752 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