]> git.saurik.com Git - wxWidgets.git/blob - src/msw/datecontrols.cpp
initial native implementation of wxCalendarCtrl for MSW
[wxWidgets.git] / src / msw / datecontrols.cpp
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: src/msw/datecontrols.cpp
3 // Purpose: implementation of date controls helper functions
4 // Author: Vadim Zeitlin
5 // Created: 2008-04-04
6 // RCS-ID: $Id$
7 // Copyright: (c) 2008 Vadim Zeitlin <vadim@wxwidgets.org>
8 // Licence: wxWindows licence
9 ///////////////////////////////////////////////////////////////////////////////
10
11 // ============================================================================
12 // declarations
13 // ============================================================================
14
15 // ----------------------------------------------------------------------------
16 // headers
17 // ----------------------------------------------------------------------------
18
19 // for compilers that support precompilation, includes "wx.h".
20 #include "wx/wxprec.h"
21
22 #ifdef __BORLANDC__
23 #pragma hdrstop
24 #endif
25
26 #ifndef WX_PRECOMP
27 #endif // WX_PRECOMP
28
29 #if wxUSE_DATEPICKCTRL || wxUSE_CALENDARCTRL
30
31 #include "wx/msw/private/datecontrols.h"
32
33 #include "wx/dynlib.h"
34
35 // ============================================================================
36 // implementation
37 // ============================================================================
38
39 bool wxMSWDateControls::CheckInitialization()
40 {
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
45 // it explicitly
46
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 )
51 {
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
54 s_initResult = false;
55
56 if ( wxApp::GetComCtl32Version() < 470 )
57 {
58 wxLogError(_("This system doesn't support date controls, please upgrade your version of comctl32.dll"));
59
60 return false;
61 }
62
63 #if wxUSE_DYNLIB_CLASS
64 INITCOMMONCONTROLSEX icex;
65 icex.dwSize = sizeof(icex);
66 icex.dwICC = ICC_DATE_CLASSES;
67
68 wxDynamicLibrary dllComCtl32(_T("comctl32.dll") , wxDL_VERBATIM);
69
70 if ( dllComCtl32.IsLoaded() )
71 {
72 typedef BOOL (WINAPI *ICCEx_t)(INITCOMMONCONTROLSEX *);
73 wxDYNLIB_FUNCTION( ICCEx_t, InitCommonControlsEx, dllComCtl32 );
74
75 if ( pfnInitCommonControlsEx )
76 {
77 s_initResult = (*pfnInitCommonControlsEx)(&icex);
78 }
79 }
80 #endif // wxUSE_DYNLIB_CLASS
81 }
82
83 return s_initResult != 0;
84 }
85
86 #endif // wxUSE_DATEPICKCTRL || wxUSE_CALENDARCTRL