[83e312]: ExpDTDlg.cpp Maximize Restore History

Download this file

ExpDTDlg.cpp    97 lines (74 with data), 2.6 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
// expDT.cpp : implementation file
//
#include "stdafx.h"
#include "ExpDTDlg.h"
#include "corelib/util.h"
// CExpDTDlg dialog
void CExpDTDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
}
BEGIN_MESSAGE_MAP(CExpDTDlg, CDialog)
ON_BN_CLICKED(IDOK, &CExpDTDlg::OnBnClickedOk)
END_MESSAGE_MAP()
BOOL CExpDTDlg::OnInitDialog()
{
TCHAR szBuf[64]; // workspace
CString sTimeFormat; // the time format being worked on
CString sSearch; // the string to search for
int nIndex; // index of the string, if found
CDialog::OnInitDialog();
// First get the time format picture.
VERIFY(::GetLocaleInfo ( LOCALE_USER_DEFAULT, LOCALE_STIMEFORMAT, szBuf, 64));
sTimeFormat = szBuf;
// Next get the separator character.
VERIFY(::GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_STIME, szBuf, 64));
// Search for ":ss".
sSearch = szBuf;
sSearch += _T("ss");
nIndex = sTimeFormat.Find(sSearch);
if (nIndex != -1) {
// Found it! Remove it from the format picture.
sTimeFormat.Delete(nIndex, sSearch.GetLength());
} else {
// No ":ss", so try ":s".
sSearch = szBuf;
sSearch += _T("s");
nIndex = sTimeFormat.Find(sSearch);
if (nIndex != -1 ) {
// Found it! Remove it from the format picture.
sTimeFormat.Delete(nIndex, sSearch.GetLength());
}
}
m_pTimeCtl = (CDateTimeCtrl*)GetDlgItem(IDC_EXPIRYTIME);
m_pDateCtl = (CDateTimeCtrl*)GetDlgItem(IDC_EXPIRYDATE);
m_pTimeCtl->SetFormat(sTimeFormat);
time_t tt;
CTime ct, xt;
if (!PWSUtil::VerifyASCDateTimeString(m_ascLTime, tt)) {
CTime now(CTime::GetCurrentTime());
ct = CTime(now.GetYear(), now.GetMonth(), now.GetDay(), 0, 0, 0, -1);
m_ascLTime = "Never";
} else {
xt = CTime(tt);
ct = CTime(xt.GetYear(), xt.GetMonth(), xt.GetDay(), 0, 0, 0, -1);
}
m_pDateCtl->SetTime(&ct);
m_pTimeCtl->SetTime(&ct);
GetDlgItem(IDC_STATIC_CURRENT_LTIME)->SetWindowText(m_ascLTime);
return TRUE;
}
void CExpDTDlg::OnBnClickedOk()
{
CTime LTime, LDate, LDateTime;
DWORD dwResult;
dwResult = m_pTimeCtl->GetTime(LTime);
ASSERT(dwResult == GDT_VALID);
dwResult = m_pDateCtl->GetTime(LDate);
ASSERT(dwResult == GDT_VALID);
LDateTime = CTime(LDate.GetYear(), LDate.GetMonth(), LDate.GetDay(),
LTime.GetHour(), LTime.GetMinute(), 0, -1);
m_tttLTime = (time_t)LDateTime.GetTime();
m_ascLTime = (CMyString)LDateTime.Format("%a %b %d %H:%M:00 %Y");
OnOK();
}