return true;
}
+void wxChoice::SetLabel(const wxString& label)
+{
+ if ( FindString(label) == wxNOT_FOUND )
+ {
+ // unless we explicitly do this here, CB_GETCURSEL will continue to
+ // return the index of the previously selected item which will result
+ // in wrongly replacing the value being set now with the previously
+ // value if the user simply opens and closes (without selecting
+ // anything) the combobox popup
+ SetSelection(-1);
+ }
+
+ wxChoiceBase::SetLabel(label);
+}
+
bool wxChoice::Create(wxWindow *parent,
wxWindowID id,
const wxPoint& pos,
// we have to delete and add back the string as there is no way to change a
// string in place
- // we need to preserve the client data
- void *data;
- if ( m_clientDataItemsType != wxClientData_None )
- {
- data = DoGetItemClientData(n);
- }
- else // no client data
- {
- data = NULL;
- }
+ // we need to preserve the client data manually
+ void *oldData = NULL;
+ wxClientData *oldObjData = NULL;
+ if ( HasClientUntypedData() )
+ oldData = GetClientData(n);
+ else if ( HasClientObjectData() )
+ oldObjData = GetClientObject(n);
::SendMessage(GetHwnd(), CB_DELETESTRING, n, 0);
::SendMessage(GetHwnd(), CB_INSERTSTRING, n, (LPARAM)s.wx_str() );
- if ( data )
- {
- DoSetItemClientData(n, data);
- }
- //else: it's already NULL by default
+ // restore the client data
+ if ( oldData )
+ SetClientData(n, oldData);
+ else if ( oldObjData )
+ SetClientObject(n, oldObjData);
InvalidateBestSize();
}