replace wxGetMultipleChoices() with wxGetSelectedChoices() which allows to distinguish between cancelling the dialog and not selecting any items in it (closes #10057)

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@59417 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2009-03-07 15:39:09 +00:00
parent c10c791ba9
commit e5cfb314ae
5 changed files with 112 additions and 27 deletions

View File

@@ -809,25 +809,32 @@ void MyFrame::MultiChoice(wxCommandEvent& WXUNUSED(event) )
};
wxArrayInt selections;
size_t count = wxGetMultipleChoices(selections,
const int count = wxGetSelectedChoices(selections,
_T("This is a small sample\n")
_T("A multi-choice convenience dialog"),
_T("Please select a value"),
WXSIZEOF(choices), choices,
this);
if ( count )
if ( count >= 0 )
{
wxString msg;
msg.Printf(wxT("You selected %u items:\n"), (unsigned)count);
for ( size_t n = 0; n < count; n++ )
if ( count == 0 )
{
msg += wxString::Format(wxT("\t%u: %u (%s)\n"),
(unsigned)n, (unsigned)selections[n],
choices[selections[n]].c_str());
msg = wxT("You did not select any items");
}
else
{
msg.Printf(wxT("You selected %u items:\n"), (unsigned)count);
for ( int n = 0; n < count; n++ )
{
msg += wxString::Format(wxT("\t%u: %u (%s)\n"),
(unsigned)n, (unsigned)selections[n],
choices[selections[n]].c_str());
}
}
wxLogMessage(msg);
}
//else: cancelled or nothing selected
//else: cancelled
}
#endif // wxUSE_CHOICEDLG