1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: src/msw/datecontrols.cpp
3 // Purpose: implementation of date controls helper functions
4 // Author: Vadim Zeitlin
6 // Copyright: (c) 2008 Vadim Zeitlin <vadim@wxwidgets.org>
7 // Licence: wxWindows licence
8 ///////////////////////////////////////////////////////////////////////////////
10 // ============================================================================
12 // ============================================================================
14 // ----------------------------------------------------------------------------
16 // ----------------------------------------------------------------------------
18 // for compilers that support precompilation, includes "wx.h".
19 #include "wx/wxprec.h"
27 #include "wx/msw/wrapcctl.h"
30 #if wxUSE_DATEPICKCTRL || wxUSE_CALENDARCTRL
32 #include "wx/msw/private/datecontrols.h"
34 #include "wx/dynlib.h"
36 // ============================================================================
38 // ============================================================================
40 bool wxMSWDateControls::CheckInitialization()
42 // although we already call InitCommonControls() in app.cpp which is
43 // supposed to initialize all common controls, in comctl32.dll 4.72 (and
44 // presumably earlier versions 4.70 and 4.71, date time picker not being
45 // supported in < 4.70 anyhow) it does not do it and we have to initialize
48 // this is initially set to -1 to indicate that we need to perform the
49 // initialization and gets set to false or true depending on its result
50 static int s_initResult
= -1; // MT-ok: used from GUI thread only
51 if ( s_initResult
== -1 )
53 // in any case do nothing the next time, the result won't change and
54 // it's enough to give the error only once
57 if ( wxApp::GetComCtl32Version() < 470 )
59 wxLogError(_("This system doesn't support date controls, please upgrade your version of comctl32.dll"));
64 #if wxUSE_DYNLIB_CLASS
65 INITCOMMONCONTROLSEX icex
;
66 icex
.dwSize
= sizeof(icex
);
67 icex
.dwICC
= ICC_DATE_CLASSES
;
69 // see comment in wxApp::GetComCtl32Version() explaining the
71 wxLoadedDLL
dllComCtl32(wxT("comctl32.dll"));
72 if ( dllComCtl32
.IsLoaded() )
76 typedef BOOL (WINAPI
*ICCEx_t
)(INITCOMMONCONTROLSEX
*);
77 wxDYNLIB_FUNCTION( ICCEx_t
, InitCommonControlsEx
, dllComCtl32
);
79 if ( pfnInitCommonControlsEx
)
81 s_initResult
= (*pfnInitCommonControlsEx
)(&icex
);
84 #endif // wxUSE_DYNLIB_CLASS
87 return s_initResult
!= 0;
90 #endif // wxUSE_DATEPICKCTRL || wxUSE_CALENDARCTRL