본문 바로가기
코드/c/c++

간단한 callback 함수 만들기..

by WeZZ 2008. 9. 19.



haeder 선언 부분

void samplecallback(unsigned int count);

typedef void (* SAMCALLBACK)(unsigned int Count);


class CCallback
{

public:
 SAMCALLBACK m_Callback;
}


void CCallback ::OnButton1()
{
 // TODO: Add your control notification handler code here

// typedef void(* CallBack)(int count);
 m_Callback = samplecallback;
 // callback 등록 하는 부분.
}

void samplecallback(unsigned int count)
{
 ::MessageBox(NULL, "CallBack routine", "CallBack routine",MB_OK);
}

void CCallback ::OnButton2()
{
 // TODO: Add your control notification handler code here
 unsigned int Count =1;

 m_Callback(Count); // callback 호출.
}