Home > Software engineering >  Why a calendar control the next time don't agree?
Why a calendar control the next time don't agree?

Time:09-27

 void CXxcDlg: : OnSelectMonthcalendar1 (pResult LRESULT pNMHDR NMHDR *, *) 
{
//TODO: Add your the control notification handler code here
CTime l_time;
Cstrings l_cstime;
The UpdateData (1);
L_time=m_date. GetTime ();//m_date calendar control CTime class variable
L_cstime=l_time. The Format (" % % Y - m - H: % d % % m: % S ");
AfxMessageBox (l_cstime);
* pResult=0;
}

But show the date isn't consistent with choice??

CodePudding user response:

This is the result of running

CodePudding user response:

Baidu search relevant keywords,

CodePudding user response:

Suggested that bind a control variable, rather than what CTime variables, such as:
 
CTime time;
M_month. GetCurSel (time);//CMonthCalCtrl m_month;
Cstrings STR=_T (" ");
STR. The Format (_T (" %. 4 d - %. 2 d - %. The 2 d %. A 2 d - %. The 2 d - %. The 2 d "), and time. The GetYear (), time, GetMonth (), time, GetDay (), time. GetHour (), time. GetMinute (), time. GetSecond ());
AfxMessageBox (STR);

CodePudding user response:

Void CListCtrl3Dlg: : OnSelchangeMonthcalendar (NMHDR * pNMHDR, LRESULT * pResult)
{
//TODO: Add your the control notification handler code here
LPNMSELCHANGE pSelChange=reinterpret_cast & lt; LPNMSELCHANGE> (pNMHDR);
SYSTEMTIME st={0};
M_Month. GetCurSel (& amp; St);

Cstrings strOut;
StrOut. The Format (" % d on % d % d ", st. wYear, st. wMonth, st. wDay);
AfxMessageBox (strOut);

* pResult=0;
}

CodePudding user response:

CDateTimeCtrl:
 
Void CELawyer: : OnDatetimechangeDatetimepicker1 (NMHDR * pNMHDR, LRESULT * pResult)
{
//TODO: Add your the control notification handler code here
SYSTEMTIME st={0};

DWORD dw=m_DtPick1. GetTime (& amp; St);
//
Cstrings strOut;
StrOut. The Format (" % d on % d % d ", st. wYear, st. wMonth, st. wDay);
AfxMessageBox (strOut);

* pResult=0;
}

CodePudding user response:

May control the BUG
Binding CMonthCalCtrl, use GetCurSel method

 
Void CDlg5Dlg: : OnSelchangeMonthcalendar1 (NMHDR * pNMHDR, LRESULT * pResult)
{
//TODO: Add your the control notification handler code here
SYSTEMTIME tmSys;
M_DateCtrl. GetCurSel (& amp; TmSys);

Cstrings szData;
SzData. The Format (_T (" % d % % 4 d - 02-02 d "),
TmSys wYear, tmSys wMonth, tmSys. WDay);
TRACE (_T (" % s \ n "), (LPCTSTR) szData);

* pResult=0;
}

  • Related