From 4cd1ed991c6654612521be12efa5a9814ad033a7 Mon Sep 17 00:00:00 2001 From: Ryan Norton Date: Sun, 7 Nov 2004 00:09:39 +0000 Subject: [PATCH] fix for [ 950550 ] wxChoice - wxEmptyString (wxChoice::FindString doesn't work with empty strings) - confirmed on win2k git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@30326 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/msw/choice.cpp | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/src/msw/choice.cpp b/src/msw/choice.cpp index 0848b22251..90e3f2b7c3 100644 --- a/src/msw/choice.cpp +++ b/src/msw/choice.cpp @@ -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 } -- 2.45.2