+ wxClientDC dc(wx_const_cast(wxDatePickerCtrl *, this));
+ dc.SetFont(GetFont());
+
+ // we can't use FormatDate() here as the CRT doesn't always use the same
+ // format as the date picker control
+ wxString s;
+ for ( int len = 100; ; len *= 2 )
+ {
+ if ( ::GetDateFormat
+ (
+ LOCALE_USER_DEFAULT, // the control should use the same
+ DATE_SHORTDATE, // the format used by the control
+ NULL, // use current date (we don't care)
+ NULL, // no custom format
+ wxStringBuffer(s, len), // output buffer
+ len // and its length
+ ) )
+ {
+ // success
+ break;
+ }
+
+ const DWORD rc = ::GetLastError();
+ if ( rc != ERROR_INSUFFICIENT_BUFFER )
+ {
+ wxLogApiError(_T("GetDateFormat"), rc);
+
+ // fall back on wxDateTime, what else to do?
+ s = wxDateTime::Today().FormatDate();
+ break;
+ }
+ }