The information in this article applies to:
SYMPTOMSWhen you call the COleDateTime members (SetDate, SetTime, and SetDateTime), the return value indicates failure even though the call is successful. This may cause code that checks the return value to believe incorrectly that the call failed. CAUSEThis behavior is caused by a problem in the COleDateTime code. COleDateTime defines the following enumeration:
The problem occurs because SetDate, SetTime, and SetDateTime all return
'valid' if successful. However 'valid' is defined to be 0 in the
DateTimeStatus enumeration, which translates to a Boolean FALSE. The code
should check for success and return TRUE or FALSE.
RESOLUTIONCall COleDateTime::GetStatus after each call to SetDate, SetTime, or SetDateTime. Then compare the value returned by GetStatus() against 'valid' to check for success. The "More Information" section of this article provides an example. STATUSMicrosoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article. This bug has been corrected in the Visual C++ 4.2b technology update. MORE INFORMATIONBecause of the problem outlined previously in this article, code that checks the return value from these functions may believe that a failure has occurred when in fact the Date/Time was set correctly. For example, the following code will ASSERT even though the call was successful:
To work around this problem, test the success of the call by calling the
COleDateTime::GetStatus() member. Compare the value returned by GetStatus()
against 'valid' to check for success as shown in this example:
Additional query words: kbVC400bug
Keywords : kbole kbMFC kbVC kbVC420fix |
Last Reviewed: July 29, 1999 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |