// shutDlg.cpp : implementation file
// Download by http://www.codefans.net
#include "stdafx.h"
#include "shut.h"
#include "shutDlg.h"
#include "winexit.h"
#include "about.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CShutDlg dialog
CShutDlg::CShutDlg(CWnd* pParent /*=NULL*/)
: CDialog(CShutDlg::IDD, pParent)
{count=0;
//{{AFX_DATA_INIT(CShutDlg)
m_usertime = 0;
//}}AFX_DATA_INIT
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CShutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CShutDlg)
DDX_Control(pDX, IDC_PROGRESS1, m_progress);
DDX_Control(pDX, IDOK2, m_sd);
DDX_DateTimeCtrl(pDX, IDC_DATETIMEPICKER1, m_usertime);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CShutDlg, CDialog)
//{{AFX_MSG_MAP(CShutDlg)
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_BN_CLICKED(IDOK2, OnOk2)
ON_WM_TIMER()
ON_BN_CLICKED(IDC_HIDE, OnHide)
ON_BN_CLICKED(IDC_SET, OnSet)
ON_NOTIFY(NM_KILLFOCUS, IDC_DATETIMEPICKER1, OnKillfocusDatetimepicker1)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CShutDlg message handlers
BOOL CShutDlg::OnInitDialog()
{
CDialog::OnInitDialog();
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
// TODO: Add extra initialization here
flag=1;
m_sd.EnableWindow(FALSE);
m_progress.SetRange(1,15);
m_progress.SetStep(1);
m_progress.SetPos(1);
SetTimer(1,1000,NULL);
return TRUE; // return TRUE unless you set the focus to a control
}
// If you add a minimize button to your dialog, you will need the code below
// to draw the icon. For MFC applications using the document/view model,
// this is automatically done for you by the framework.
void CShutDlg::OnPaint()
{
if(flag==0)ShowWindow(SW_HIDE);
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();
}
}
HCURSOR CShutDlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
void CShutDlg::OnOk2()
{
winexit wine;
KillTimer(3);
if(wine.DoModal()==IDOK)
{
CDialog::OnOK();
}
else SetTimer(3,1000,NULL);
}
void CShutDlg::OnTimer(UINT nIDEvent)
{
CTime tt=CTime::GetCurrentTime();
if(nIDEvent==2)
{
if(((tt.GetMinute()==58)&&(tt.GetHour()==/*(t[0]>>16)*/11))
||((tt.GetMinute()==28)&&(tt.GetHour()==17)))
{
//
m_sd.EnableWindow(TRUE);
GetDlgItem(IDC_HIDE)->EnableWindow(FALSE);
SetTimer(3,1000,NULL);
flag=1;
SetDlgItemText(IDC_NOTE,_T("订时时间到,请关机! 注意:15秒后将自动关机!"));
count=0;
m_progress.ShowWindow(SW_SHOW);
this->ShowWindow(SW_SHOW);
KillTimer(2);
}
else
if((tt.GetMinute()==m_usertime.GetMinute())&&(tt.GetHour()==/*(t[0]>>16)*/m_usertime.GetHour()))
{SetTimer(1,1000,NULL);
flag=1;
this->ShowWindow(SW_SHOW);
AfxMessageBox("自定义时间到!");
}
}
else
{
CString st;
st=tt.Format("%x %A %X");
SetDlgItemText(IDC_TIME,st);
if(nIDEvent==3)
{
count++;
m_progress.StepIt();
st.Format("关机 %i",15-count);
SetDlgItemText(IDOK2,st);
if(count==15){
KillTimer(3);
::ExitWindowsEx(EWX_SHUTDOWN,0);
}
}
}
CDialog::OnTimer(nIDEvent);
}
void CShutDlg::OnHide()
{
flag=0;
SetTimer(2,60000,NULL);
KillTimer(1);
Invalidate();
}
void CShutDlg::OnSet()
{CAbout about;
about.DoModal();
}
void CShutDlg::OnKillfocusDatetimepicker1(NMHDR* pNMHDR, LRESULT* pResult)
{
UpdateData(TRUE);
*pResult = 0;
}
可隐藏的C++定时关机、定时唤醒程序
5星 · 超过95%的资源 需积分: 12 158 浏览量
2010-07-22
17:21:55
上传
评论
收藏 23KB RAR 举报
a350752425
- 粉丝: 54
- 资源: 2136
最新资源
- 电力场景设备漏油检测数据集VOC+YOLO格式338张1类别.7z
- 基于yolov8+pyqt5实现精美界面支持图片视频和摄像检测源码.zip
- 用C语言为母亲节献上一份特别的祝福.zip
- LCD1602液晶显示屏的深入探索与实用指南.zip
- 基于Matlab人脸肤色定理的教师人数统计+源代码+全部数据+文档说明+详细注释+使用说明+截图(高分课程设计)
- 基于Matlab霍夫曼变换的表盘读数识别+源代码+全部数据+文档说明+详细注释+使用说明+截图(高分课程设计)
- 基于Matlab火灾烟雾检测源码带GUI界面+源代码+全部数据+文档说明+详细注释+使用说明+截图(高分课程设计)
- 基于Matlab的恶劣天气交通标志识别系统+源代码+全部数据+文档说明+详细注释+使用说明+截图(高分课程设计)
- 基于MATLAB的霍夫曼变换的表盘示数识别+源代码+全部数据+文档说明+详细注释+使用说明+截图(高分课程设计)
- 基于Matlab的车道线识别系统 +源代码+全部数据+文档说明+详细注释+使用说明+截图(高分课程设计)
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈