Windows の C++ で wxwidgets を使用したスレッドの作成に関連して読んでいましたが、次のコード スニペットの意味を理解できません。
以下はプロジェクトの一部です:-
Myfirm.cpp
My thread.h
Mythread.cpp
in Myfirm.cpp
the following code is not understood by me:-
BEGIN_EVENT_TABLE(MyFrm,wxFrame)
EVT_COMMAND(wxID_ANY, wxEVT_MYTHREAD, MyFrm::OnMyThread)
END_EVENT_TABLE()
void MyFrm::PerformCalculation(int someParameter){//not sure what is it
MyThread *thread = new Mythread(this, someParameter);
thread->Create();
thread->Run();
}
void MyFrm::OnMyThread(wxCommandEvent& event)//here also the clarity is not good
{
unsigned char* temp = (unsigned char*)event.GetClientData();
delete[] temp;
}
in this exampe what is even more confusing is that , it does not contain a main()
function
in Mythread.h
BEGIN_DECLARE_EVENT_TYPES()
DECLARE_EVENT_TYPE(wxEVT_MYTHREAD, -1)
END_DECLARE_EVENT_TYPES()
in Mythread.cpp
DEFINE_EVENT_TYPE(wxEVT_MYTHREAD)
MyThread::MyThread(wxEvtHandler* pParent, int param) : wxThread(wxTHREAD_DETACHED),
m_pParent(pParent)
{
m_param = param;
}
void* MyThread::Entry()
{
wxCommandEvent evt(wxEVT_MYTHREAD, GetId());
evt.SetInt(r);
evt.SetClientData(data);
wxPostEvent(m_pParent, evt);
return 0;
}
i am atill wondering how does the following code works and have no idea about where
where the main function is?
ありがとう