]> git.saurik.com Git - wxWidgets.git/blobdiff - samples/widgets/slider.cpp
fix for potential crash when conversion fails
[wxWidgets.git] / samples / widgets / slider.cpp
index 75c5839332a503fadf151878711ab63cade465e8..ec7b0bf6045a1018369e383e98a6a3b76e5b39e1 100644 (file)
@@ -95,6 +95,9 @@ public:
     virtual wxControl *GetWidget() const { return m_slider; }
     virtual void RecreateWidget() { CreateSlider(); }
 
+    // lazy creation of the content
+    virtual void CreateContent();
+
 protected:
     // event handlers
     void OnButtonReset(wxCommandEvent& event);
@@ -208,10 +211,8 @@ IMPLEMENT_WIDGETS_PAGE(SliderWidgetsPage, _T("Slider"), FAMILY_CTRLS );
 
 SliderWidgetsPage::SliderWidgetsPage(WidgetsBookCtrl *book,
                                      wxImageList *imaglist)
-                  : WidgetsPage(book)
+                  : WidgetsPage(book, imaglist, slider_xpm)
 {
-    imaglist->Add(wxBitmap(slider_xpm));
-
     // init everything
     m_min = 0;
     m_max = 100;
@@ -225,7 +226,10 @@ SliderWidgetsPage::SliderWidgetsPage(WidgetsBookCtrl *book,
 
     m_slider = (wxSlider *)NULL;
     m_sizerSlider = (wxSizer *)NULL;
+}
 
+void SliderWidgetsPage::CreateContent()
+{
     wxSizer *sizerTop = new wxBoxSizer(wxHORIZONTAL);
 
     // left pane