|
// 아마 이런씩으로 되어 있을 겁니다.
class TThread
{
// 정적 멤버 함수 : this는 쓸 수 없지만 인자로 받는 건 된다.
static DWORD WINAPI Thread_Start_Routine(LPVOID param)
{
TThread *This = (TThread*)param; // 받은 인자로 This를 구하여 멤버를 호출한다.
This->Execute();
}
TThread()
{
hThread = CreateThread(NULL,
0,
(LPTHREAD_START_ROUTINE)Thread_Start_Routine,
(LPVOID)this, // 자신을 인자로 넘긴다.
0,
&dwThreadId);
}
// 가상 멤버 함수 : this를 쓸 수 있다.
virtual void Execute()
{
//
}
};
// 폼을 접근하고 싶다면 상속으로 약간 수정만 하시면
class TFormHandlerThread : public TThread
{
TFrom* theForm;
public:
TFormHandlerThread(TFrom* AForm, bool ...)
{
theForm = AForm;
}
// From 에 접근 할 수 있다.
void PrintTime()
{
((TfmMain*)theForm)->Caption = Now().DateTimeString();
}
// this 사용이 가능하다.
virtual void Execute()
{
this->PrintTime()
}
};
|