X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/f499e61407a950d2b2568556b100630998f1581c..cf2372509cef60accf833de95b1688e0c28b0567:/src/msw/choice.cpp diff --git a/src/msw/choice.cpp b/src/msw/choice.cpp index 1ebacc20e4..90e3f2b7c3 100644 --- a/src/msw/choice.cpp +++ b/src/msw/choice.cpp @@ -28,7 +28,7 @@ #pragma hdrstop #endif -#if wxUSE_CHOICE && !defined(__SMARTPHONE__) +#if wxUSE_CHOICE && !(defined(__SMARTPHONE__) && defined(__WXWINCE__)) #ifndef WX_PRECOMP #include "wx/choice.h" @@ -333,10 +333,26 @@ int wxChoice::FindString(const wxString& s) const return wxNOT_FOUND; #else // !Watcom - int pos = (int)SendMessage(GetHwnd(), CB_FINDSTRINGEXACT, - (WPARAM)-1, (LPARAM)s.c_str()); - - return pos == LB_ERR ? wxNOT_FOUND : pos; + //TODO: Evidently some MSW versions (all?) don't like empty strings + //passed to SendMessage, so we have to do it ourselves in that case + if ( s.size() == 0 ) + { + int count = GetCount(); + for ( int i = 0; i < count; i++ ) + { + if ( GetString(i).size() == 0 ) + return i; + } + + return wxNOT_FOUND; + } + else + { + int pos = (int)SendMessage(GetHwnd(), CB_FINDSTRINGEXACT, + (WPARAM)-1, (LPARAM)s.c_str()); + + return pos == LB_ERR ? wxNOT_FOUND : pos; + } #endif // Watcom/!Watcom } @@ -620,4 +636,4 @@ WXHBRUSH wxChoice::OnCtlColor(WXHDC pDC, WXHWND WXUNUSED(pWnd), WXUINT WXUNUSED( return (WXHBRUSH)brush->GetResourceHandle(); } -#endif // wxUSE_CHOICE && !__SMARTPHONE__ +#endif // wxUSE_CHOICE && !(__SMARTPHONE__ && __WXWINCE__)