📄 maindlg.cpp
字号:
// MainDlg.cpp : implementation file
//
#include "stdafx.h"
#include "timeclose.h"
#include "MainDlg.h"
#include "MainFrm.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CMainDlg dialog
CMainDlg::CMainDlg(CWnd* pParent /*=NULL*/)
: CDialog(CMainDlg::IDD, pParent),how(0),hh(0),mm(0)
{
//{{AFX_DATA_INIT(CMainDlg)
m_hour = 0;
m_min = 0;
//}}AFX_DATA_INIT
}
void CMainDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CMainDlg)
DDX_Control(pDX, IDC_COMBO1, m_how);
DDX_Control(pDX, IDC_BUTTON2, m_stop);
DDX_Control(pDX, IDC_BUTTON1, m_run);
DDX_Text(pDX, IDC_EDIT1, m_hour);
DDX_Text(pDX, IDC_EDIT2, m_min);
//}}AFX_DATA_MAP
}
BOOL CMainDlg::OnInitDialog(){
CDialog::OnInitDialog();
m_how.SetCurSel(0);
if(run==true){
m_run.EnableWindow(FALSE);
SetWindowText("执行中……");
}
else{
m_stop.EnableWindow(FALSE);
SetWindowText("等待中……");
}
m_hour=hh;
m_min=mm;
UpdateData(FALSE);
time=CTime::GetCurrentTime();
currenttime.Format("%d:%d:%d",time.GetHour(),time.GetMinute(),time.GetSecond());
SetDlgItemText(IDC_TIME,currenttime);
SetTimer(1,1000,NULL);
return TRUE;
}
BEGIN_MESSAGE_MAP(CMainDlg, CDialog)
//{{AFX_MSG_MAP(CMainDlg)
ON_WM_TIMER()
ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
ON_BN_CLICKED(IDC_BUTTON2, OnButton2)
ON_WM_CLOSE()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CMainDlg message handlers
void CMainDlg::OnTimer(UINT nIDEvent)
{
if(nIDEvent==1){
time=CTime::GetCurrentTime();
currenttime.Format("%d:%d:%d",time.GetHour(),time.GetMinute(),time.GetSecond());
SetDlgItemText(IDC_TIME,currenttime);
}
CDialog::OnTimer(nIDEvent);
}
void CMainDlg::OnButton1()
{
UpdateData(TRUE);
if(m_hour<0||m_hour>23||m_min<0||m_min>59){
MessageBox("输入不合法!");
return;
}
m_run.EnableWindow(FALSE);
m_stop.EnableWindow(TRUE);
SetWindowText("执行中……");
::PostMessage(hwnd,WM_RUN,0,0);
switch(m_how.GetCurSel()){
case 0:
how=0;
break;
case 1:
how=1;
break;
case 2:
how=2;
break;
}
OnOK();
}
void CMainDlg::OnButton2()
{
m_stop.EnableWindow(FALSE);
m_run.EnableWindow(TRUE);
SetWindowText("等待中……");
::PostMessage(hwnd,WM_STOP,0,0);
}
void CMainDlg::OnClose()
{
OnOK();
CDialog::OnClose();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -