Then I copy some code, and design my own.
Code: Select all
class MyFooEvent: public wxCommandEvent
{
public:
MyFooEvent(wxEventType commandType = MY_NEW_TYPE, int id = 0)
: wxCommandEvent(commandType, id) { }
// You *must* copy here the data to be transported
MyFooEvent(const MyFooEvent& event)
: wxCommandEvent(event) { this->SetPoint(event.GetPoint()); }
// Required for sending with wxPostEvent()
wxEvent* Clone() const { return new MyFooEvent(*this); }
wxRealPoint GetPoint() const { return m_RealPoint; }
void SetPoint(const wxRealPoint& rp) { m_RealPoint = rp; }
private:
wxRealPoint m_RealPoint;
};
Code: Select all
...
MyFooEvent(wxEventType commandType = MY_NEW_TYPE, int id = 0)
: wxEvent(commandType, id) { }
...
So, I try to check the error, and finally I found that in the wxEvent's document, there is one important note:
wxWidgets: wxEvent Class Reference
So, I see that if I change the wxCommandEvent to wxEvent, the constructor's parameter should be swapped (id is the first parameter)Also please notice that the order of parameters in this constructor is different from almost all the derived classes which specify the event type as the first argument.
Code: Select all
...
MyFooEvent(wxEventType commandType = MY_NEW_TYPE, int id = 0)
: wxEvent(id, commandType) { }
...
Thanks.