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"
28 #include "wx/msw/wrapcctl.h"
31 #if wxUSE_DATEPICKCTRL || wxUSE_CALENDARCTRL
33 #include "wx/msw/private/datecontrols.h"
35 #include "wx/dynlib.h"
37 // ============================================================================
39 // ============================================================================
41 bool wxMSWDateControls::CheckInitialization()
43 // although we already call InitCommonControls() in app.cpp which is
44 // supposed to initialize all common controls, in comctl32.dll 4.72 (and
45 // presumably earlier versions 4.70 and 4.71, date time picker not being
46 // supported in < 4.70 anyhow) it does not do it and we have to initialize
49 // this is initially set to -1 to indicate that we need to perform the
50 // initialization and gets set to false or true depending on its result
51 static int s_initResult
= -1; // MT-ok: used from GUI thread only
52 if ( s_initResult
== -1 )
54 // in any case do nothing the next time, the result won't change and
55 // it's enough to give the error only once
58 if ( wxApp::GetComCtl32Version() < 470 )
60 wxLogError(_("This system doesn't support date controls, please upgrade your version of comctl32.dll"));
65 #if wxUSE_DYNLIB_CLASS
66 INITCOMMONCONTROLSEX icex
;
67 icex
.dwSize
= sizeof(icex
);
68 icex
.dwICC
= ICC_DATE_CLASSES
;
70 // see comment in wxApp::GetComCtl32Version() explaining the
72 wxLoadedDLL
dllComCtl32(_T("comctl32.dll"));
73 if ( dllComCtl32
.IsLoaded() )
77 typedef BOOL (WINAPI
*ICCEx_t
)(INITCOMMONCONTROLSEX
*);
78 wxDYNLIB_FUNCTION( ICCEx_t
, InitCommonControlsEx
, dllComCtl32
);
80 if ( pfnInitCommonControlsEx
)
82 s_initResult
= (*pfnInitCommonControlsEx
)(&icex
);
85 #endif // wxUSE_DYNLIB_CLASS
88 return s_initResult
!= 0;
91 #endif // wxUSE_DATEPICKCTRL || wxUSE_CALENDARCTRL