• Articles
  • A win32 multi-function stopwatch using S
Jan 21, 2012 (last update: Jan 23, 2012)

A win32 multi-function stopwatch using SFML

Score: 3.1/5 (27 votes)
*****
I present here a complete win32 program for a multi-function stopwatch. The graphics library used is SFML v1.6 ( the current release version ).

I assume that the reader is familiar with using SFML.
Here is a link to their site: http://www.sfml-dev.org/index.php

Description of the stop watch: There are two modes of operation.

1) Clock mode. This is the primary mode. Any number of time trials can be recorded.


The start button starts and stops the clock.
The reset button will reset the time for the current trial to 0.
The new button creates a new time trial.

The reset and the new buttons will work when the clock is either running or stopped. This permits a 'lap' feature, where one time is stopped and the next time begins instantly.

The remaining buttons work only when the clock is stopped.
The prev and next buttons allow scrolling through the recorded trials. You may reset or continue the time on any recorded trial.
The delete button will erase the trial currently selected.
The deleteAll button will erase all trials, so be careful about hitting that one!

2) Stat mode. This mode gives some statistics for the recorded trials. It is available only if there is more than 1 trial recorded.


The min and max buttons will show the least and greatest times recorded and the respective trial numbers.
The avg button displays the simple average of all the recorded trials.
The total button adds up all of the time trial values.
The stdDev button shows the standard deviation among the recorded trials.

All files are contained in the .zip file attached here:
stopWatch4_windows.zip
The source files are:
1)main.cpp This is the code for the main().
2,3) button.h and button.cpp
This is the abstract base class for the buttons used in the program.
4,5) buttonFromImage.h and .cpp
Derived from button. All of the buttons used in the project are of this type.

Simply unzip the zip file then run the stopWatch4_windows file. It should work!


Acknowledgement: My thanks to Albatross and to Ultifinitus for creating the button images used here!

I hope you like the program. Please PM me regarding any problems you find (or other feedback).

Regards - fun2code

Attachments: [stopWatch4_windows.zip]