Click here to Skip to main content
15,887,676 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
HI,
How to get Day, Month, Year from MFC DATETIMEPICKER

I need to save the Day, Month, Year from MFC DATETIMEPICKER as CString when the date is changed on DATETIMEPICKER.
I have added control variable to the date time picker button,
and added the action listener to that button control(OnDtnDatetimechangeDatetimepicker(NMHDR *pNMHDR, LRESULT *pResult)),

But how to get Day, Month and year from that control variable?
Thanks
Posted
Updated 20-Sep-12 17:36pm
v2

1 solution

You Need to typecast pNMHDR to LPNMDATETIMECHANGE.Refer MSDN for NMDATETIMECHANGE

Sample code:

C++
LPNMDATETIMECHANGE pDTChange = reinterpret_cast<lpnmdatetimechange>(pNMHDR);
CString strDDMMYYY;
strDDMMYYY.Format("DD::MM::YYYY %02d::%02d::%04d", pDTChange->st.wDay, pDTChange->st.wMonth, pDTChange->st.wYear);
</lpnmdatetimechange>
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900