]> git.saurik.com Git - wxWidgets.git/blobdiff - samples/widgets/listbox.cpp
fix dialogs sample to remember last color with generic color dialog
[wxWidgets.git] / samples / widgets / listbox.cpp
index fa373865323505e84bee4a43e88f177de320883c..65ae57555e6953297a8a469e8a5aa1b43a98db16 100644 (file)
@@ -1,5 +1,5 @@
 /////////////////////////////////////////////////////////////////////////////
-// Program:     wxWindows Widgets Sample
+// Program:     wxWidgets Widgets Sample
 // Name:        listbox.cpp
 // Purpose:     Part of the widgets sample showing wxListbox
 // Author:      Vadim Zeitlin
@@ -24,6 +24,8 @@
     #pragma hdrstop
 #endif
 
+#if wxUSE_LISTBOX
+
 // for all others, include the necessary headers
 #ifndef WX_PRECOMP
     #include "wx/log.h"
@@ -43,7 +45,7 @@
 #include "wx/checklst.h"
 
 #include "widgets.h"
-#if 1
+
 #include "icons/listbox.xpm"
 
 // ----------------------------------------------------------------------------
@@ -493,10 +495,13 @@ void ListboxWidgetsPage::OnUpdateUIAddSeveral(wxUpdateUIEvent& event)
 
 void ListboxWidgetsPage::OnListbox(wxCommandEvent& event)
 {
-    long sel = event.GetInt();
+    long sel = event.GetSelection();
     m_textDelete->SetValue(wxString::Format(_T("%ld"), sel));
 
-    wxLogMessage(_T("Listbox item %ld selected"), sel);
+    if (event.IsSelection())
+        wxLogMessage(_T("Listbox item %ld selected"), sel);
+    else
+        wxLogMessage(_T("Listbox item %ld deselected"), sel);
 }
 
 void ListboxWidgetsPage::OnListboxDClick(wxCommandEvent& event)
@@ -514,4 +519,4 @@ void ListboxWidgetsPage::OnCheckOrRadioBox(wxCommandEvent& WXUNUSED(event))
     CreateLbox();
 }
 
-#endif
+#endif // wxUSE_LISTBOX