1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: src/msw/datecontrols.cpp
3 // Purpose: implementation of date controls helper functions
4 // Author: Vadim Zeitlin
7 // Copyright: (c) 2008 Vadim Zeitlin <vadim@wxwidgets.org>
8 // Licence: wxWindows licence
9 ///////////////////////////////////////////////////////////////////////////////
11 // ============================================================================
13 // ============================================================================
15 // ----------------------------------------------------------------------------
17 // ----------------------------------------------------------------------------
19 // for compilers that support precompilation, includes "wx.h".
20 #include "wx/wxprec.h"
29 #if wxUSE_DATEPICKCTRL || wxUSE_CALENDARCTRL
31 #include "wx/msw/private/datecontrols.h"
33 #include "wx/dynlib.h"
35 // ============================================================================
37 // ============================================================================
39 bool wxMSWDateControls::CheckInitialization()
41 // although we already call InitCommonControls() in app.cpp which is
42 // supposed to initialize all common controls, in comctl32.dll 4.72 (and
43 // presumably earlier versions 4.70 and 4.71, date time picker not being
44 // supported in < 4.70 anyhow) it does not do it and we have to initialize
47 // this is initially set to -1 to indicate that we need to perform the
48 // initialization and gets set to false or true depending on its result
49 static int s_initResult
= -1; // MT-ok: used from GUI thread only
50 if ( s_initResult
== -1 )
52 // in any case do nothing the next time, the result won't change and
53 // it's enough to give the error only once
56 if ( wxApp::GetComCtl32Version() < 470 )
58 wxLogError(_("This system doesn't support date controls, please upgrade your version of comctl32.dll"));
63 #if wxUSE_DYNLIB_CLASS
64 INITCOMMONCONTROLSEX icex
;
65 icex
.dwSize
= sizeof(icex
);
66 icex
.dwICC
= ICC_DATE_CLASSES
;
68 wxDynamicLibrary
dllComCtl32(_T("comctl32.dll") , wxDL_VERBATIM
);
70 if ( dllComCtl32
.IsLoaded() )
72 typedef BOOL (WINAPI
*ICCEx_t
)(INITCOMMONCONTROLSEX
*);
73 wxDYNLIB_FUNCTION( ICCEx_t
, InitCommonControlsEx
, dllComCtl32
);
75 if ( pfnInitCommonControlsEx
)
77 s_initResult
= (*pfnInitCommonControlsEx
)(&icex
);
80 #endif // wxUSE_DYNLIB_CLASS
83 return s_initResult
!= 0;
86 #endif // wxUSE_DATEPICKCTRL || wxUSE_CALENDARCTRL