X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/3180bc0e63fc0feea1fcdb756752b700c27b9773..4ad7af2b83d24c75a0cdf32c7e5ee1c2cc4dd543:/src/msw/choice.cpp

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
 }