好友
阅读权限10
听众
最后登录1970-1-1
|
VC++ 开发
软件:
WorkTimer.rar
(824.95 KB, 下载次数: 98)
源码:
WorkTimer Code.rar
(257.73 KB, 下载次数: 24)
void CWorkTimerDlg::OnBnClickedOk()
{
// TODO: 在此添加控件通知处理程序代码
//CDialogEx::OnOK();
CString strText;
GetDlgItemText(IDOK,strText);
if(strText == _T("开始"))
{
int nHour = ((CComboBox*)GetDlgItem(IDC_COMBO_HOUR))->GetCurSel();
int nMinute = ((CComboBox*)GetDlgItem(IDC_COMBO_MINUTE))->GetCurSel();
int nSeconds = ((CComboBox*)GetDlgItem(IDC_COMBO_SECONDS))->GetCurSel();
if(nHour == 0 && nMinute == 0 && nSeconds == 0)
{
MessageBox(_T("请设置时间"),_T("提示"),32);
return;
}
SetControl(FALSE);
m_uTimeId = timeSetEvent(1000,1,TimeCallBack,(DWORD_PTR)this,TIME_PERIODIC);
SetDlgItemText(IDOK,_T("停止"));
}
else
{
if(m_uTimeId)
{
timeKillEvent(m_uTimeId);
m_uTimeId = 0;
}
SetControl();
SetDlgItemText(IDOK,_T("开始"));
PlaySound(NULL, NULL, SND_PURGE);
}
}
void CALLBACK TimeCallBack(UINT uTimerID,UINT uMsg,DWORD_PTR dwUser,DWORD_PTR dw1,DWORD_PTR dw2)
{
CWorkTimerDlg* pDlg = (CWorkTimerDlg*)dwUser;
if(pDlg->m_uTimeId == uTimerID)
{
int nHour = ((CComboBox*)pDlg->GetDlgItem(IDC_COMBO_HOUR))->GetCurSel();
int nMinute = ((CComboBox*)pDlg->GetDlgItem(IDC_COMBO_MINUTE))->GetCurSel();
int nSeconds = ((CComboBox*)pDlg->GetDlgItem(IDC_COMBO_SECONDS))->GetCurSel();
if(nSeconds)
{
((CComboBox*)pDlg->GetDlgItem(IDC_COMBO_SECONDS))->SetCurSel(nSeconds-1);
}
else if(nMinute)
{
((CComboBox*)pDlg->GetDlgItem(IDC_COMBO_MINUTE))->SetCurSel(nMinute-1);
((CComboBox*)pDlg->GetDlgItem(IDC_COMBO_SECONDS))->SetCurSel(59);
}
else if(nHour)
{
((CComboBox*)pDlg->GetDlgItem(IDC_COMBO_HOUR))->SetCurSel(nHour-1);
((CComboBox*)pDlg->GetDlgItem(IDC_COMBO_MINUTE))->SetCurSel(59);
}
else
{
timeKillEvent(pDlg->m_uTimeId);
pDlg->m_uTimeId = 0;
//pDlg->SetControl();
//pDlg->SetDlgItemText(IDOK,_T("开始"));
PlaySound((LPCTSTR)IDR_STARTWIN,AfxGetInstanceHandle(),SND_RESOURCE | SND_ASYNC | SND_LOOP);
}
}
}
|
免费评分
-
查看全部评分
|
发帖前要善用【论坛搜索】功能,那里可能会有你要找的答案或者已经有人发布过相同内容了,请勿重复发帖。 |
|
|
|
|