git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@55
c3d73ce0-8a6f-49c7-b76d-
6d57e0e08775
bool Create(wxWindow *parent, const wxString& message, const wxString& caption,
const wxStringList& choices, char **clientData = NULL, long style = wxOK|wxCANCEL|wxCENTRE, const wxPoint& pos = wxDefaultPosition);
bool Create(wxWindow *parent, const wxString& message, const wxString& caption,
const wxStringList& choices, char **clientData = NULL, long style = wxOK|wxCANCEL|wxCENTRE, const wxPoint& pos = wxDefaultPosition);
+ void SetSelection(int sel) ;
inline int GetSelection(void) const { return m_selection; }
inline wxString GetStringSelection(void) const { return m_stringSelection; }
inline char *GetSelectionClientData(void) const { return m_clientData; }
inline int GetSelection(void) const { return m_selection; }
inline wxString GetStringSelection(void) const { return m_stringSelection; }
inline char *GetSelectionClientData(void) const { return m_clientData; }
typedef wxGenericColourDialog wxColourDialog;
typedef wxGenericColourDialog wxColourDialog;
void MyFrame::SingleChoice(wxCommandEvent& event)
{
void MyFrame::SingleChoice(wxCommandEvent& event)
{
- const wxString choices[] = { "One", "Two", "Three", "Four", "Five" } ;
- int n = 5;
+ const wxString choices[] = { "One", "Two", "Three", "Four", "Five" } ;
+ int n = 5;
- wxSingleChoiceDialog dialog(this, "This is a small sample\nA single-choice convenience dialog",
- "Please select a value", n, (const wxString *)choices);
+ wxSingleChoiceDialog dialog(this, "This is a small sample\nA single-choice convenience dialog",
+ "Please select a value", n, (const wxString *)choices);
- if (dialog.ShowModal() == wxID_OK)
- {
- wxMessageDialog dialog2(this, dialog.GetStringSelection(), "Got string");
- dialog2.ShowModal();
- }
+ dialog.SetSelection(2);
+
+ if (dialog.ShowModal() == wxID_OK)
+ {
+ wxMessageDialog dialog2(this, dialog.GetStringSelection(), "Got string");
+ dialog2.ShowModal();
+ }
}
void MyFrame::FileOpen(wxCommandEvent& event)
}
void MyFrame::FileOpen(wxCommandEvent& event)
wxListBox *listBox = new wxListBox(this, wxID_LISTBOX, wxPoint(-1, -1), wxSize(240, 160),
n, choices);
wxListBox *listBox = new wxListBox(this, wxID_LISTBOX, wxPoint(-1, -1), wxSize(240, 160),
n, choices);
+ listBox->SetSelection(m_selection);
if ( clientData )
{
int i;
if ( clientData )
{
int i;
+// Set the selection
+void wxSingleChoiceDialog::SetSelection(int sel)
+{
+ wxListBox *listBox = (wxListBox *)FindWindow(wxID_LISTBOX);
+ if (listBox)
+ {
+ listBox->SetSelection(sel);
+ }
+ m_selection = sel;
+}
+
void wxSingleChoiceDialog::OnOK(wxCommandEvent& WXUNUSED(event))
{
wxListBox *listBox = (wxListBox *)FindWindow(wxID_LISTBOX);
void wxSingleChoiceDialog::OnOK(wxCommandEvent& WXUNUSED(event))
{
wxListBox *listBox = (wxListBox *)FindWindow(wxID_LISTBOX);