]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/choice.cpp
Added check for sel == -1
[wxWidgets.git] / src / msw / choice.cpp
index c6a9f7909f1286279a058759f7965290cddc90df..90714d1e5ad0a88d8dc52708e1aa06e5276b6cd8 100644 (file)
@@ -318,15 +318,18 @@ bool wxChoice::MSWCommand(WXUINT param, WXWORD WXUNUSED(id))
     }
 
     int n = GetSelection();
-    wxCommandEvent event(wxEVT_COMMAND_CHOICE_SELECTED, m_windowId);
-    event.SetInt(n);
-    event.SetEventObject(this);
-    event.SetString(GetStringSelection());
-    if ( HasClientObjectData() )
-        event.SetClientObject( GetClientObject(n) );
-    else if ( HasClientUntypedData() )
-        event.SetClientData( GetClientData(n) );
-    ProcessCommand(event);
+    if (n > -1)
+    {
+        wxCommandEvent event(wxEVT_COMMAND_CHOICE_SELECTED, m_windowId);
+        event.SetInt(n);
+        event.SetEventObject(this);
+        event.SetString(GetStringSelection());
+        if ( HasClientObjectData() )
+            event.SetClientObject( GetClientObject(n) );
+        else if ( HasClientUntypedData() )
+            event.SetClientData( GetClientData(n) );
+        ProcessCommand(event);
+    }
 
     return TRUE;
 }