]> git.saurik.com Git - wxWidgets.git/blob - src/msw/datecontrols.cpp
Make public headers compatible with Objective-C++ with ARC.
[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 // Copyright: (c) 2008 Vadim Zeitlin <vadim@wxwidgets.org>
7 // Licence: wxWindows licence
8 ///////////////////////////////////////////////////////////////////////////////
9
10 // ============================================================================
11 // declarations
12 // ============================================================================
13
14 // ----------------------------------------------------------------------------
15 // headers
16 // ----------------------------------------------------------------------------
17
18 // for compilers that support precompilation, includes "wx.h".
19 #include "wx/wxprec.h"
20
21 #ifdef __BORLANDC__
22 #pragma hdrstop
23 #endif
24
25 #ifndef WX_PRECOMP
26 #include "wx/app.h"
27 #include "wx/msw/wrapcctl.h"
28 #endif // WX_PRECOMP
29
30 #if wxUSE_DATEPICKCTRL || wxUSE_CALENDARCTRL
31
32 #include "wx/msw/private/datecontrols.h"
33
34 #include "wx/dynlib.h"
35
36 // ============================================================================
37 // implementation
38 // ============================================================================
39
40 bool wxMSWDateControls::CheckInitialization()
41 {
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
46 // it explicitly
47
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 )
52 {
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
55 s_initResult = false;
56
57 if ( wxApp::GetComCtl32Version() < 470 )
58 {
59 wxLogError(_("This system doesn't support date controls, please upgrade your version of comctl32.dll"));
60
61 return false;
62 }
63
64 #if wxUSE_DYNLIB_CLASS
65 INITCOMMONCONTROLSEX icex;
66 icex.dwSize = sizeof(icex);
67 icex.dwICC = ICC_DATE_CLASSES;
68
69 // see comment in wxApp::GetComCtl32Version() explaining the
70 // use of wxLoadedDLL
71 wxLoadedDLL dllComCtl32(wxT("comctl32.dll"));
72 if ( dllComCtl32.IsLoaded() )
73 {
74 wxLogNull noLog;
75
76 typedef BOOL (WINAPI *ICCEx_t)(INITCOMMONCONTROLSEX *);
77 wxDYNLIB_FUNCTION( ICCEx_t, InitCommonControlsEx, dllComCtl32 );
78
79 if ( pfnInitCommonControlsEx )
80 {
81 s_initResult = (*pfnInitCommonControlsEx)(&icex);
82 }
83 }
84 #endif // wxUSE_DYNLIB_CLASS
85 }
86
87 return s_initResult != 0;
88 }
89
90 #endif // wxUSE_DATEPICKCTRL || wxUSE_CALENDARCTRL