]> git.saurik.com Git - wxWidgets.git/commitdiff
filter out duplicate date changed events sent by the native control (part of bug...
authorVadim Zeitlin <vadim@wxwidgets.org>
Sat, 21 Oct 2006 16:29:33 +0000 (16:29 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Sat, 21 Oct 2006 16:29:33 +0000 (16:29 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@42207 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/msw/datectrl.h
src/msw/datectrl.cpp

index d4b8bc74fb98c60151e49cc8a809521aa6c93672..c4078c6f6893edb7f64534a0109e465e8c1684f5 100644 (file)
@@ -60,6 +60,9 @@ public:
 protected:
     virtual wxSize DoGetBestSize() const;
 
 protected:
     virtual wxSize DoGetBestSize() const;
 
+    // the date currently shown by the control, may be invalid
+    wxDateTime m_date;
+
 
     DECLARE_DYNAMIC_CLASS_NO_COPY(wxDatePickerCtrl)
 };
 
     DECLARE_DYNAMIC_CLASS_NO_COPY(wxDatePickerCtrl)
 };
index ebe60e9318bfaba06347c32b13f23b0c834f96f7..c9129f87565be99bb5679012dc028edd206d74ec 100644 (file)
@@ -253,10 +253,13 @@ void wxDatePickerCtrl::SetValue(const wxDateTime& dt)
     {
         wxLogDebug(_T("DateTime_SetSystemtime() failed"));
     }
     {
         wxLogDebug(_T("DateTime_SetSystemtime() failed"));
     }
+
+    m_date = dt;
 }
 
 wxDateTime wxDatePickerCtrl::GetValue() const
 {
 }
 
 wxDateTime wxDatePickerCtrl::GetValue() const
 {
+#ifdef __WXDEBUG__
     wxDateTime dt;
     SYSTEMTIME st;
     if ( DateTime_GetSystemtime(GetHwnd(), &st) == GDT_VALID )
     wxDateTime dt;
     SYSTEMTIME st;
     if ( DateTime_GetSystemtime(GetHwnd(), &st) == GDT_VALID )
@@ -264,7 +267,12 @@ wxDateTime wxDatePickerCtrl::GetValue() const
         wxFromSystemTime(&dt, st);
     }
 
         wxFromSystemTime(&dt, st);
     }
 
-    return dt;
+    wxASSERT_MSG( m_date.IsValid() == dt.IsValid() &&
+                    (!dt.IsValid() || dt == m_date),
+                  _T("bug in wxDatePickerCtrl: m_date not in sync") );
+#endif // __WXDEBUG__
+
+    return m_date;
 }
 
 void wxDatePickerCtrl::SetRange(const wxDateTime& dt1, const wxDateTime& dt2)
 }
 
 void wxDatePickerCtrl::SetRange(const wxDateTime& dt1, const wxDateTime& dt2)
@@ -331,11 +339,17 @@ wxDatePickerCtrl::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result)
             if ( dtch->dwFlags == GDT_VALID )
                 wxFromSystemTime(&dt, dtch->st);
 
             if ( dtch->dwFlags == GDT_VALID )
                 wxFromSystemTime(&dt, dtch->st);
 
-            wxDateEvent event(this, dt, wxEVT_DATE_CHANGED);
-            if ( GetEventHandler()->ProcessEvent(event) )
+            // filter out duplicate DTN_DATETIMECHANGE events which the native
+            // control sends us when using wxDP_DROPDOWN style
+            if ( !m_date.IsValid() || dt != m_date )
             {
             {
-                *result = 0;
-                return true;
+                m_date = dt;
+                wxDateEvent event(this, dt, wxEVT_DATE_CHANGED);
+                if ( GetEventHandler()->ProcessEvent(event) )
+                {
+                    *result = 0;
+                    return true;
+                }
             }
         }
     }
             }
         }
     }