开发者

MFC time tool for stopwatch implementation

开发者 https://www.devze.com 2023-01-21 12:24 出处:网络
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.

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:

  1. In OnInitDialog, add SetTimer(ID_MY_STOPWATCH,1000,NULL)
  2. In your message map you need ON_WM_TIMER()
  3. 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); }

0

精彩评论

暂无评论...
验证码 换一张
取 消