avoid asserts by not using GetSelection() with multi selection listbox

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@39916 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin 2006-06-30 23:25:18 +00:00
parent 1a8b677e3b
commit 45262a3415

View File

@ -1218,8 +1218,6 @@ void MyPanel::OnChangeColour(wxCommandEvent& WXUNUSED(event))
void MyPanel::OnListBox( wxCommandEvent &event )
{
// GetParent()->Move(100, 100);
if (event.GetInt() == -1)
{
m_text->AppendText( _T("ListBox has no selections anymore\n") );
@ -1232,9 +1230,15 @@ void MyPanel::OnListBox( wxCommandEvent &event )
m_text->AppendText( _T("ListBox event selection string is: '") );
m_text->AppendText( event.GetString() );
m_text->AppendText( _T("'\n") );
m_text->AppendText( _T("ListBox control selection string is: '") );
m_text->AppendText( listbox->GetStringSelection() );
m_text->AppendText( _T("'\n") );
// can't use GetStringSelection() with multiple selections, there could be
// more than one of them
if ( !listbox->HasFlag(wxLB_MULTIPLE) )
{
m_text->AppendText( _T("ListBox control selection string is: '") );
m_text->AppendText( listbox->GetStringSelection() );
m_text->AppendText( _T("'\n") );
}
wxStringClientData *obj = ((wxStringClientData *)event.GetClientObject());
m_text->AppendText( _T("ListBox event client data string is: '") );
@ -1245,7 +1249,7 @@ void MyPanel::OnListBox( wxCommandEvent &event )
m_text->AppendText( _T("'\n") );
m_text->AppendText( _T("ListBox control client data string is: '") );
obj = (wxStringClientData *)listbox->GetClientObject(listbox->GetSelection());
obj = (wxStringClientData *)listbox->GetClientObject(event.GetInt());
if (obj)
m_text->AppendText( obj->GetData() );
else