wxSliderの使い方(wxWidgets)

#include <wx/wx.h>
#include <wx/slider.h>
#include <iostream>

using namespace std;

const int ID_SLIDER = 1;

class MyFrame : public wxFrame
{
public:
  MyFrame();
  wxSlider* slider;
  void OnScroll(wxScrollEvent& event);
  int pos;
};


class MyApp : public wxApp
{
public:
  virtual bool OnInit();
};

IMPLEMENT_APP(MyApp)

bool MyApp::OnInit()
{
  MyFrame* frame = new MyFrame();
  frame->Show(true);
  return true;
}

MyFrame::MyFrame()
    : wxFrame(NULL,-1,"slider test",wxDefaultPosition,wxSize(400,400))
{
    wxPanel *panel = new wxPanel(this);
    slider = new wxSlider(panel,ID_SLIDER,0,0,100,wxPoint(10,40),wxSize(240,-1));
    Connect(ID_SLIDER,wxEVT_COMMAND_SLIDER_UPDATED,
            wxScrollEventHandler(MyFrame::OnScroll));

}

void MyFrame::OnScroll(wxScrollEvent& event)
{
   pos = slider -> GetValue();  
   cout << pos << endl;
}