+ dialog.SetSelection(2);
+
+ if (dialog.ShowModal() == wxID_OK)
+ {
+ wxMessageDialog dialog2(this, dialog.GetStringSelection(), "Got string");
+ dialog2.ShowModal();
+ }
+}
+
+void MyFrame::MultiChoice(wxCommandEvent& WXUNUSED(event) )
+{
+ const wxString choices[] =
+ {
+ "One", "Two", "Three", "Four", "Five",
+ "Six", "Seven", "Eight", "Nine", "Ten",
+ "Eleven", "Twelve", "Seventeen",
+ };
+
+ wxArrayInt selections;
+ size_t count = wxGetMultipleChoices(selections,
+ "This is a small sample\n"
+ "A multi-choice convenience dialog",
+ "Please select a value",
+ WXSIZEOF(choices), choices,
+ this);
+ if ( count )
+ {
+ wxString msg;
+ msg.Printf(wxT("You selected %u items:\n"), count);
+ for ( size_t n = 0; n < count; n++ )
+ {
+ msg += wxString::Format(wxT("\t%u: %u (%s)\n"), n, selections[n],
+ choices[selections[n]].c_str());
+ }
+ wxLogMessage(msg);
+ }
+ //else: cancelled or nothing selected
+}
+
+void MyFrame::FileOpen(wxCommandEvent& WXUNUSED(event) )
+{
+ wxFileDialog dialog
+ (
+ this,
+ _T("Testing open file dialog"),
+ _T(""),
+ _T(""),
+ _T("C++ files (*.h;*.cpp)|*.h;*.cpp")
+ );
+
+ if (dialog.ShowModal() == wxID_OK)
+ {
+ wxString info;
+ info.Printf(_T("Full file name: %s\n")
+ _T("Path: %s\n")
+ _T("Name: %s"),
+ dialog.GetPath().c_str(),
+ dialog.GetDirectory().c_str(),
+ dialog.GetFilename().c_str());
+ wxMessageDialog dialog2(this, info, "Selected file");
+ dialog2.ShowModal();
+ }
+}
+
+// this shows how to take advantage of specifying a default extension in the
+// call to wxFileSelector: it is remembered after each new call and the next
+// one will use it by default
+void MyFrame::FileOpen2(wxCommandEvent& WXUNUSED(event) )
+{
+ static wxString s_extDef;
+ wxString path = wxFileSelector(
+ _T("Select the file to load"),
+ _T(""), _T(""),
+ s_extDef,
+ _T("Waveform (*.wav)|*.wav|Plain text (*.txt)|*.txt|All files (*.*)|*.*"),
+ wxCHANGE_DIR,
+ this
+ );
+
+ if ( !path )
+ return;
+
+ // it is just a sample, would use wxSplitPath in real program
+ s_extDef = path.AfterLast(_T('.'));
+
+ wxLogMessage(_T("You selected the file '%s', remembered extension '%s'"),
+ (const wxChar*) path, (const wxChar*) s_extDef);
+}
+
+void MyFrame::FilesOpen(wxCommandEvent& WXUNUSED(event) )
+{
+ wxFileDialog dialog(this, "Testing open multiple file dialog",
+ "", "", wxFileSelectorDefaultWildcardStr,
+ wxMULTIPLE);
+
+ if (dialog.ShowModal() == wxID_OK)
+ {
+ wxArrayString paths, filenames;
+
+ dialog.GetPaths(paths);
+ dialog.GetFilenames(filenames);
+
+ wxString msg, s;
+ size_t count = paths.GetCount();
+ for ( size_t n = 0; n < count; n++ )
+ {
+ s.Printf(_T("File %d: %s (%s)\n"),
+ n, paths[n].c_str(), filenames[n].c_str());
+
+ msg += s;
+ }
+
+ wxMessageDialog dialog2(this, msg, "Selected files");
+ dialog2.ShowModal();
+ }
+}
+
+void MyFrame::FileSave(wxCommandEvent& WXUNUSED(event) )
+{
+ wxFileDialog dialog(this, "Testing save file dialog", "", "myletter.txt",
+ "Text files (*.txt)|*.txt|Document files (*.doc)|*.doc",
+ wxSAVE|wxOVERWRITE_PROMPT);
+
+ if (dialog.ShowModal() == wxID_OK)
+ {
+ wxChar buf[400];
+ wxSprintf(buf, _T("%s, filter %d"), (const wxChar*)dialog.GetPath(), dialog.GetFilterIndex());
+ wxMessageDialog dialog2(this, wxString(buf), "Selected path");
+ dialog2.ShowModal();
+ }