DateDialog.cpp
上传用户:shilei2004
上传日期:2020-07-18
资源大小:83k
文件大小:2k
- // DateDialog.cpp : implementation file
- //
- #include "stdafx.h"
- #include "Edit.h"
- #include "DateDialog.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // CDateDialog dialog
- SYSTEMTIME CDateDialog::m_time;
- LCID CDateDialog::m_id;
- CListBox* CDateDialog::m_pListBox = NULL;
- CDateDialog::CDateDialog(CWnd* pParent /*=NULL*/)
- : CDialog(CDateDialog::IDD, pParent)
- {
- //{{AFX_DATA_INIT(CDateDialog)
- m_strSel = _T("");
- //}}AFX_DATA_INIT
- }
- void CDateDialog::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(CDateDialog)
- DDX_Control(pDX, IDC_DATEDIALOG_LIST, m_listBox);
- DDX_LBString(pDX, IDC_DATEDIALOG_LIST, m_strSel);
- //}}AFX_DATA_MAP
- }
- BEGIN_MESSAGE_MAP(CDateDialog, CDialog)
- //{{AFX_MSG_MAP(CDateDialog)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // CDateDialog message handlers
- BOOL CDateDialog::OnInitDialog()
- {
- CDialog::OnInitDialog();
-
- // TODO: Add extra initialization here
- m_pListBox = &m_listBox; // set static member
- GetLocalTime(&m_time);
- // m_id = GetUserDefaultLCID();
-
- EnumDateFormats(DateFmtEnumProc, m_id, DATE_SHORTDATE);
- EnumDateFormats(DateFmtEnumProc, m_id, DATE_LONGDATE);
- EnumTimeFormats(TimeFmtEnumProc, m_id, 0);
- m_pListBox = NULL;
- m_listBox.SetCurSel(0);
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
- }
- BOOL CALLBACK CDateDialog::DateFmtEnumProc(LPTSTR lpszFormatString)
- {
- ASSERT(m_pListBox != NULL);
- TCHAR buf[256];
- VERIFY(GetDateFormat(m_id, 0, &m_time, lpszFormatString, buf, 256));
- if (m_pListBox->FindStringExact(-1,buf) == CB_ERR)
- m_pListBox->AddString(buf);
- return TRUE;
- }
- BOOL CALLBACK CDateDialog::TimeFmtEnumProc(LPTSTR lpszFormatString)
- {
- ASSERT(m_pListBox != NULL);
- TCHAR buf[256];
- VERIFY(GetTimeFormat(m_id, 0, &m_time, lpszFormatString, buf, 256));
- if (m_pListBox->FindStringExact(-1,buf) == CB_ERR)
- m_pListBox->AddString(buf);
- return TRUE;
- }