Article ID: 235355 - Last Review: November 21, 2006 - Revision: 2.1 PRB: CMonthCalCtl::GetCurSel(CTime) Returns Wrong Value
This article was previously published under Q235355 SYMPTOMS
When you use the CMonthCalCtrl::GetCurSel(CTime) to get the date selected
from the Month Calendar Common control, the date in the CTime class is incorrect.
CAUSE
MFC's implementation of CMonthCalCtrl::GetCurSel() for the CTime class calls SendMessage(MCM_GETCURSEL, &sysTime) where sysTime is a SYSTEMTIME structure. The MCM_GETCURSEL message does not fill in the hours, minutes, and seconds part of the sysTime Structure with valid values. However, the constructor for CTime class takes these values into consideration, so the date in CTime class is incorrect.
RESOLUTION
The workaround is to use the CMonthCalCtrl::GetCurSel(SYSTEMTIME*) version of GetCurSel for this class to get the correct date. The code will look like the following example:
STATUS
This behavior is by design.
| Other Resources Other Support Sites
CommunityArticle Translations |






Windows Live
Facebook
Twitter
Linkedin
Digg it
Yahoo
Delicious
StumbleUpon
Yammer
Reddit
Technorati
FriendFeed
Email
Back to the top