TCalendarEdit text gets cleared when control loses focus
Borland's Object Windows Library for the modern age
Brought to you by:
jogybl,
sebas_ledesma
The problem is that
TDate::AsString()by default uses the "mmm dd,yy" format for printing the date, the parsing is done using theTDate(LPCTSTR)constructor, which internally callsTDate::ParseFrom(LPCTSTR str, LPCTSTR format), and its implementation does not support the "mmm dd,yy" format.Two possible quick fixes for the
TCalendarEditclass:TDate::SetPrintOption(TDate::WinIntSection)to set the format forTDate::AsString()when setting the text in the edit control. The problem is that first of all, this changes the behavior of the control, as the date is now printed in a different format, and second - the SetPrintOption method is static and affects all instances of the TDate class. Even if restoring the old value immediately after printing the date, there is a small risk that other threads may be affected.TDate(const tistream& s);constructor that supports "mmm dd,yy" format.It is possible also to change the
TDate(LPCTSTR)constructor to internally create a stream and use the stream parsing, but that may affect existing code.The best long-term solution may be to ditch the usage of TDate in TCalendarEdit and refactor it to make use of the standard chrono library.
The second proposed fix implemented in [r7859].
Related
Commit: [r7859]