void StopWatch_Stop(HWND hDlg){ if(!m_start.QuadPart) return; KillTimer(hDlg,1); m_paused = 1; OnTimer(hDlg); // update time text m_start.QuadPart = 0; SetDlgItemText(hDlg, IDC_SW_START, L"Start (s)"); EnableDlgItemSafeFocus(hDlg, IDC_SW_RESET, 0, IDC_SW_START); }
void StopWatch_Reset(HWND hDlg){ if(!m_start.QuadPart) return; SetDlgItemText(hDlg, IDC_SW_ELAPSED, TIMETEXT_DEFAULT); ListView_DeleteAllItems(GetDlgItem(hDlg,IDC_SW_LAPS)); if(m_paused){ // paused m_start.QuadPart=0; EnableDlgItemSafeFocus(hDlg,IDC_SW_RESET,0,IDC_SW_START); }else{ // running QueryPerformanceCounter(&m_start); m_lap=m_start; } }
//================================================================================================ //-----------------------------//-------------------+++--> Stop & Cancel a Currently Running Timer: void OnStopTimer(HWND hWnd) //------------------------------------------------------------+++--> { HWND timer_cb = GetDlgItem(hWnd, IDC_TIMERNAME); char name[GEN_BUFF]; int idx; ComboBox_GetText(timer_cb, name, sizeof(name)); for(idx=0; idx<m_timers; ++idx) { if(!strcmp(name, m_timer[idx].name)) { int id=m_timer[idx].id; timeropt_t* pts=(timeropt_t*)ComboBox_GetItemData(timer_cb, id);; StopTimer(id); pts->bActive = 0; EnableDlgItem(hWnd, IDOK, 1); EnableDlgItemSafeFocus(hWnd, IDCB_STOPTIMER, 0, IDOK); break; } } }