📄 changetimedlg.cpp
字号:
// ChangeTimeDlg.cpp : implementation file
//
#include "stdafx.h"
#include "ChangeTime.h"
#include "ChangeTimeDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CChangeTimeDlg dialog
CChangeTimeDlg::CChangeTimeDlg(CWnd* pParent /*=NULL*/)
: CDialog(CChangeTimeDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CChangeTimeDlg)
m_strTime = 0;
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CChangeTimeDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CChangeTimeDlg)
DDX_DateTimeCtrl(pDX, IDC_DATETIMEPICKER1, m_strTime);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CChangeTimeDlg, CDialog)
//{{AFX_MSG_MAP(CChangeTimeDlg)
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_BN_CLICKED(IDC_CHANGETIME, OnChangetime)
ON_BN_CLICKED(IDC_CHANGETIME2, OnChangetime2)
ON_NOTIFY(DTN_CLOSEUP, IDC_DATETIMEPICKER1, OnCloseupDatetimepicker1)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CChangeTimeDlg message handlers
BOOL CChangeTimeDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
// TODO: Add extra initialization here
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 CChangeTimeDlg::OnPaint()
{
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();
}
}
// The system calls this to obtain the cursor to display while the user drags
// the minimized window.
HCURSOR CChangeTimeDlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
void CChangeTimeDlg::OnChangetime()
{
int year,month,day;
year=m_strTime.GetYear();
month=m_strTime.GetMonth();
day=m_strTime.GetDay();
SYSTEMTIME tm;
tm.wYear = year;
tm.wMonth = month;
tm.wDayOfWeek = 0;
tm.wDay = day;
tm.wHour = 0;
tm.wMinute = 0;
tm.wSecond = 0;
tm.wMilliseconds = 0;
::SetSystemTime(&tm);
}
void CChangeTimeDlg::OnChangetime2()
{
/*
time_t osBinaryTime; // C run-time time (defined in <time.h>)
time( &osBinaryTime ) ; // Get the current time from the
// operating system.
CTime time1; // Empty CTime. (0 is illegal time value.)
CTime time2 = time1; // Copy constructor.
CTime time3( osBinaryTime ); // CTime from C run-time time
CTime time4( 1999, 3, 19, 22, 15, 0 ); // 10:15PM March 19, 1999
*/
//CTime time4( 1999, 3, 19, 22, 15, 0 ); // 10:15PM March 19, 1999
//time4.Format(
}
void CChangeTimeDlg::OnCloseupDatetimepicker1(NMHDR* pNMHDR, LRESULT* pResult)
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);//!!
*pResult = 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -