X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/8d99be5f5381dad56492da02c2df1c3ec0750926..12db77cab1054d288a2b3e2d07e58ad1d6386a53:/src/msw/choice.cpp diff --git a/src/msw/choice.cpp b/src/msw/choice.cpp index 92cab89387..d157992171 100644 --- a/src/msw/choice.cpp +++ b/src/msw/choice.cpp @@ -60,7 +60,7 @@ bool wxChoice::Create(wxWindow *parent, if ( !CreateControl(parent, id, pos, size, style, validator, name) ) return FALSE; - long msStyle = WS_CHILD | CBS_DROPDOWNLIST | WS_TABSTOP | WS_VISIBLE; + long msStyle = WS_CHILD | CBS_DROPDOWNLIST | WS_TABSTOP | WS_VISIBLE | WS_HSCROLL | WS_VSCROLL; if ( style & wxCB_SORT ) msStyle |= CBS_SORT; @@ -69,10 +69,10 @@ bool wxChoice::Create(wxWindow *parent, wxASSERT_MSG( !(style & wxCB_DROPDOWN) && !(style & wxCB_READONLY) && !(style & wxCB_SIMPLE), - _T("this style flag is ignored by wxChoice, you " + wxT("this style flag is ignored by wxChoice, you " "probably want to use a wxComboBox") ); - if ( !MSWCreateControl(_T("COMBOBOX"), msStyle) ) + if ( !MSWCreateControl(wxT("COMBOBOX"), msStyle) ) return FALSE; for ( int i = 0; i < n; i++ ) @@ -89,14 +89,20 @@ bool wxChoice::Create(wxWindow *parent, // adding/deleting items to/from the list // ---------------------------------------------------------------------------- -void wxChoice::DoAppend(const wxString& item) +int wxChoice::DoAppend(const wxString& item) { - SendMessage(GetHwnd(), CB_ADDSTRING, 0, (LONG)item.c_str()); + int n = (int)SendMessage(GetHwnd(), CB_ADDSTRING, 0, (LONG)item.c_str()); + if ( n == CB_ERR ) + { + wxLogLastError("SendMessage(CB_ADDSTRING)"); + } + + return n; } void wxChoice::Delete(int n) { - wxCHECK_RET( n < GetCount(), _T("invalid item index in wxChoice::Delete") ); + wxCHECK_RET( n < GetCount(), wxT("invalid item index in wxChoice::Delete") ); SendMessage(GetHwnd(), CB_DELETESTRING, n, 0); } @@ -154,15 +160,15 @@ int wxChoice::FindString(const wxString& s) const wxString wxChoice::GetString(int n) const { size_t len = (size_t)::SendMessage(GetHwnd(), CB_GETLBTEXTLEN, n, 0); - wxString str; - if ( ::SendMessage(GetHwnd(), CB_GETLBTEXT, n, - (LPARAM)str.GetWriteBuf(len)) == CB_ERR ) - { - wxLogLastError("SendMessage(CB_GETLBTEXT)"); + wxString str = ""; + if (len) { + if ( ::SendMessage(GetHwnd(), CB_GETLBTEXT, n, + (LPARAM)str.GetWriteBuf(len)) == CB_ERR ) { + wxLogLastError("SendMessage(CB_GETLBTEXT)"); + } + str.UngetWriteBuf(); } - str.UngetWriteBuf(); - return str; } @@ -174,7 +180,7 @@ void wxChoice::DoSetClientData( int n, void* clientData ) { if ( SendMessage(GetHwnd(), CB_SETITEMDATA, n, (LPARAM)clientData) == CB_ERR ) { - wxLogLastError(_T("CB_SETITEMDATA")); + wxLogLastError(wxT("CB_SETITEMDATA")); } } @@ -183,10 +189,10 @@ void* wxChoice::DoGetClientData( int n ) const LPARAM rc = SendMessage(GetHwnd(), CB_GETITEMDATA, n, 0); if ( rc == CB_ERR ) { - wxLogLastError(_T("CB_GETITEMDATA")); + wxLogLastError(wxT("CB_GETITEMDATA")); // unfortunately, there is no way to return an error code to the user - rc = NULL; + rc = (LPARAM) NULL; } return (void *)rc;