// DataTimeDlg.cpp : implementation file
//

#include "stdafx.h"
#include "DataTimeDlg.h"

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

/////////////////////////////////////////////////////////////////////////////
// CDataTimeDlg dialog


CDataTimeDlg::CDataTimeDlg(CWnd* pParent /*=NULL*/)
	: CaplTranslateDialog(CDataTimeDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CDataTimeDlg)
	//}}AFX_DATA_INIT
	m_title= APL_T("Точка во времени");
}


void CDataTimeDlg::DoDataExchange(CDataExchange* pDX)
{
	CaplTranslateDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CDataTimeDlg)
	DDX_Control(pDX, IDC_TIME_VAL, m_time);
	DDX_Control(pDX, IDC_DATE_VAL, m_date);
	DDX_Control(pDX, IDCANCEL, m_cancel_btn);
	DDX_Control(pDX, IDOK, m_ok_btn);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CDataTimeDlg, CaplTranslateDialog)
	//{{AFX_MSG_MAP(CDataTimeDlg)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CDataTimeDlg message handlers

BOOL CDataTimeDlg::OnInitDialog() 
{
	CaplTranslateDialog::OnInitDialog();
	
	// TODO: Add extra initialization here
	m_cancel_btn.SetIcon(GetAplStdIco16(APLSTDICO_CANCEL));
	m_cancel_btn.SetFlat(FALSE);
	m_ok_btn.SetIcon(GetAplStdIco16(APLSTDICO_OK));
	m_ok_btn.SetFlat(FALSE);
	if(m_dt.m_dt!=0)
	{
		m_date.SetTime(m_dt);
		m_time.SetTime(m_dt);
	}
	SetWindowText(m_title);
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void CDataTimeDlg::OnOK() 
{
	// TODO: Add extra validation here
	COleDateTime odt0,odt1;
	m_date.GetTime(odt0);
	m_time.GetTime(odt1);

	m_dt.SetDateTime(odt0.GetYear(),odt0.GetMonth(),odt0.GetDay(),
		odt1.GetHour(),odt1.GetMinute(),odt1.GetSecond());
	CaplTranslateDialog::OnOK();
}
