I would like to implement a stop watch as part of my system. i want it to have a simple feture that when pressing start the timer runs and when pressing stop it stops.
how should i do such a thing(timer func + graphical pre开发者_如何学JAVAsentation)? *when googling i came across many things that were not suitable.
Tnx
Implementing a digital countdown is the easiest thing to do - Text field, Button, and a Timer. Implementing a graphical stopwatch is the hardest, you will need a bitmap for the watch face, then you can draw the hands on it. How much time do you want spend writing the code, versus how good should it look?
The basics are like this:
- In OnInitDialog, add SetTimer(ID_MY_STOPWATCH,1000,NULL)
- In your message map you need ON_WM_TIMER()
Then a WM_TIMER handler like this:
void CTimerTestDlg::OnTimer(UINT_PTR nIDEvent) {
// TODO: Add your message handler code here and/or call default
if (nIDEvent==ID_MY_STOPWATCH) { // Update the UI here }
CDialog::OnTimer(nIDEvent); }
精彩评论