ATimeControl::ATimeControl(AComponent* pOwner):base_class(pOwner),m_pFocusEdit(NULL) { m_iBorderWidth = 1; m_pEditHour = new AEdit(this); m_pEditMinute =new AEdit(this); m_pEditSecond = new AEdit(this); m_pLabel1 = new ALabel(this); m_pLabel2 = new ALabel(this); m_pSpin = new ASpinControl(this); m_pSpin->SetAutoSpin(false); m_pSpin->SetWidth(11); m_pSpin->SetAlign( alRight ); EVENT_CONNECT(m_pSpin,OnSpin,OnSpin); m_pEditHour->SetBorderWidth(0); m_pEditMinute->SetBorderWidth(0); m_pEditSecond->SetBorderWidth(0); m_pLabel1->SetText(L":"); m_pLabel2->SetText(L":"); ADateTime now = ADateTime::GetCurrentTime(); m_pEditHour->SetText( AString().Format(L"%02d",now.GetHour())); m_pEditMinute->SetText( AString().Format(L"%02d",now.GetMinute())); m_pEditSecond->SetText( AString().Format(L"%02d",now.GetSecond())); EVENT_CONNECT(m_pEditHour,OnFocus,OnEditFocus); EVENT_CONNECT(m_pEditMinute,OnFocus,OnEditFocus); EVENT_CONNECT(m_pEditSecond,OnFocus,OnEditFocus); EVENT_CONNECT(m_pEditHour,OnKillFocus,OnEditKillFocus); EVENT_CONNECT(m_pEditMinute,OnKillFocus,OnEditKillFocus); EVENT_CONNECT(m_pEditSecond,OnKillFocus,OnEditKillFocus); }
void ATimeControl::SetTime(const ADateTime& dt) { m_pEditHour->SetText( AString().Format(L"%02d",dt.GetHour())); m_pEditMinute->SetText( AString().Format(L"%02d",dt.GetMinute())); m_pEditSecond->SetText( AString().Format(L"%02d",dt.GetSecond())); }