filter out duplicate date changed events sent by the native control (part of bug 1482773)

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@42207 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2006-10-21 16:29:33 +00:00
parent e7e9ac91c2
commit e4164aa980
2 changed files with 22 additions and 5 deletions

View File

@@ -60,6 +60,9 @@ public:
protected: protected:
virtual wxSize DoGetBestSize() const; 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)
}; };

View 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; wxDateTime dt;
SYSTEMTIME st; SYSTEMTIME st;
if ( DateTime_GetSystemtime(GetHwnd(), &st) == GDT_VALID ) 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 ) if ( dtch->dwFlags == GDT_VALID )
wxFromSystemTime(&dt, dtch->st); wxFromSystemTime(&dt, dtch->st);
wxDateEvent event(this, dt, wxEVT_DATE_CHANGED); // filter out duplicate DTN_DATETIMECHANGE events which the native
if ( GetEventHandler()->ProcessEvent(event) ) // control sends us when using wxDP_DROPDOWN style
if ( !m_date.IsValid() || dt != m_date )
{ {
*result = 0; m_date = dt;
return true; wxDateEvent event(this, dt, wxEVT_DATE_CHANGED);
if ( GetEventHandler()->ProcessEvent(event) )
{
*result = 0;
return true;
}
} }
} }
} }