- // create the native control
- if ( !MSWCreateControl(MONTHCAL_CLASS, wxEmptyString, pos, size) )
+ // create the native control: this is a bit tricky as we want to receive
+ // double click events but the MONTHCAL_CLASS doesn't use CS_DBLCLKS style
+ // and so we create our own copy of it which does
+ static ClassRegistrar s_clsMonthCal;
+ if ( !s_clsMonthCal.IsInitialized() )
+ {
+ // get a copy of standard class and modify it
+ WNDCLASS wc;
+ if ( ::GetClassInfo(NULL, MONTHCAL_CLASS, &wc) )
+ {
+ wc.lpszClassName = wxT("_wx_SysMonthCtl32");
+ wc.style |= CS_DBLCLKS;
+ s_clsMonthCal.Register(wc);
+ }
+ else
+ {
+ wxLogLastError(_T("GetClassInfoEx(SysMonthCal32)"));
+ }
+ }
+
+ const wxChar * const clsname = s_clsMonthCal.IsRegistered()
+ ? s_clsMonthCal.GetName().wx_str()
+ : MONTHCAL_CLASS;
+
+ if ( !MSWCreateControl(clsname, wxEmptyString, pos, size) )