⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 poweroffdlg.cpp

📁 主要用于宿舍上网计时
💻 CPP
字号:
// PowerOffDlg.cpp : implementation file
//

#include "stdafx.h"
#include "A9410.h"
#include "PowerOffDlg.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CPowerOffDlg dialog


CPowerOffDlg::CPowerOffDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CPowerOffDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CPowerOffDlg)
	m_Day = 0;
	m_Hour = 0;
	m_Min = 0;
	m_Mon = 0;
	m_Sec = 0;
	m_Year = 0;
	//}}AFX_DATA_INIT
	n_ok=false;
	m_hIcon = AfxGetApp()->LoadIcon(IDI_ICON2);
}


void CPowerOffDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CPowerOffDlg)
	DDX_Text(pDX, IDC_EDIT_DAY, m_Day);
	DDV_MinMaxInt(pDX, m_Day, 1, 31);
	DDX_Text(pDX, IDC_EDIT_HOUR, m_Hour);
	DDV_MinMaxInt(pDX, m_Hour, 0, 59);
	DDX_Text(pDX, IDC_EDIT_MIN, m_Min);
	DDV_MinMaxInt(pDX, m_Min, 0, 59);
	DDX_Text(pDX, IDC_EDIT_MON, m_Mon);
	DDV_MinMaxInt(pDX, m_Mon, 1, 12);
	DDX_Text(pDX, IDC_EDIT_SEC, m_Sec);
	DDV_MinMaxInt(pDX, m_Sec, 0, 59);
	DDX_Text(pDX, IDC_EDIT_YEAR, m_Year);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CPowerOffDlg, CDialog)
	//{{AFX_MSG_MAP(CPowerOffDlg)
	ON_WM_QUERYDRAGICON()
	ON_WM_PAINT()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CPowerOffDlg message handlers

HCURSOR CPowerOffDlg::OnQueryDragIcon()
{
	return (HCURSOR) m_hIcon;
}
void CPowerOffDlg::OnOK() 
{
	// TODO: Add extra validation here
	UpdateData();
	CTime time1(m_Year,m_Mon,m_Day,m_Hour,m_Min,m_Sec);
	CTime time2;
	time2=CTime::GetCurrentTime();
	timeoff= time1- time2;
	int mins=timeoff.GetTotalMinutes();
	if(mins<1)
	{
		MessageBox("无效时间!");
	}
	else
	{
		n_ok=true;
		CDialog::OnOK();
	}
}

BOOL CPowerOffDlg::OnInitDialog() 
{
	CDialog::OnInitDialog();
	SetIcon(m_hIcon, TRUE);			// Set big icon
	SetIcon(m_hIcon, FALSE);		// Set small icon
	
	// TODO: Add extra initialization here
	CTime time=CTime::GetCurrentTime();
	m_Year=time.GetYear();
	m_Mon=time.GetMonth();
	m_Day=time.GetDay();
	m_Hour=time.GetHour();
	m_Min=time.GetMinute();
	m_Sec=time.GetSecond();
	UpdateData(false);
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void CPowerOffDlg::OnPaint() 
{	
	// TODO: Add your message handler code here
	if (IsIconic())
	{ 
		CPaintDC dc(this); // device context for painting

		SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);

		// Center icon in client rectangle
		int cxIcon = GetSystemMetrics(SM_CXICON);
		int cyIcon = GetSystemMetrics(SM_CYICON);
		CRect rect;
		GetClientRect(&rect);
		int x = (rect.Width() - cxIcon + 1) / 2;
		int y = (rect.Height() - cyIcon + 1) / 2;

		// Draw the icon
		dc.DrawIcon(x, y, m_hIcon);
	}
 
	else
	{
		CDialog::OnPaint();
	}
	// Do not call CDialog::OnPaint() for painting messages
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -