이벤트 핸들러 추적 과정


MyTextCtrl.h
#pragma  once

#include  <wx/wx.h>
class  MyTextCtrl:public  wxTextCtrl
{
public:
    MyTextCtrl(wxWindow *parent, wxWindowID id,
            const  wxString& value = wxEmptyString,
            const  wxPoint& pos = wxDefaultPosition,
            const  wxSize& size = wxDefaultSize,
            long style = 0,
            const  wxValidator& validator = wxDefaultValidator,
            const  wxString& name = wxTextCtrlNameStr);

    ~MyTextCtrl(void);
private:
   void OnChar(wxKeyEvent& event);

   DECLARE_EVENT_TABLE()
};

MyTextCtrl.cpp
#include  "MyTextCtrl.h"


BEGIN_EVENT_TABLE(MyTextCtrl,wxTextCtrl)
    EVT_CHAR(  MyTextCtrl::OnChar)
END_EVENT_TABLE()

MyTextCtrl::MyTextCtrl(wxWindow *parent, wxWindowID id,
               const wxString& value,
               const wxPoint& pos,
               const wxSize& size,
               long style,
               const wxValidator& validator,
               const wxString& name )
             :wxTextCtrl(    parent,id,value,pos,size,style,validator,name)
{
}


MyTextCtrl::~MyTextCtrl(void)
{
}

void
MyTextCtrl::OnChar(wxKeyEvent& event){
   if( ::isalpha( event.GetKeyCode()) ){
      event.Skip(true);
   }  
}

MyFrame.h
#pragma  once
#include  <wx/wx.h>

class  MyFrame:public  wxFrame
{
public:
    MyFrame(const  wxString& title);
    ~MyFrame(void);
private:
   void OnClose(wxCloseEvent& event);

   DECLARE_EVENT_TABLE()
};

MyFrame.cpp
#include  "MyFrame.h"   
#include  "MyTextCtrl.h"

BEGIN_EVENT_TABLE(MyFrame, wxFrame)
   EVT_CLOSE( MyFrame::OnClose)
END_EVENT_TABLE()


MyFrame::MyFrame(const  wxString& title)
    :wxFrame(NULL, wxID_ANY, title)
{
    wxPanel* panel = new  wxPanel(this);
   wxTextCtrl* text = new  MyTextCtrl(panel,wxID_ANY,"",wxPoint(10,10));
}


MyFrame::~MyFrame(void)
{
}


void 
MyFrame::OnClose(wxCloseEvent& event){
   wxMessageDialog* dial = new  wxMessageDialog(NULL, "정말  닫으시겠습니까?","Exit",wxYES_NO);
   int ret = dial->ShowModal();
    dial->Destroy();

   if( wxID_NO==ret){
      event.Veto();
      return;
   }

   this->Destroy();
}

MyApp.h
#pragma  once
#include  <wx/wx.h>
class  MyApp:public  wxApp
{
public:
    MyApp(void);
    ~MyApp(void);
   virtual  bool OnInit();
};

DECLARE_APP( MyApp );

MyApp.cpp
#include  "MyApp.h"
#include  "MyFrame.h"

IMPLEMENT_APP(MyApp);

MyApp::MyApp(void)
{
}


MyApp::~MyApp(void)
{
}


bool
MyApp::OnInit(){
   wxFrame* m = new  MyFrame("Text Control 2");
    m->Show(true);
   return  true;
}

- 목록:

2 thoughts on “wxPaintDC 이해하기

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>