BREW: How to use callbacks while working with BREW in C++
Simplest Way:
Make the callback Function member as static then this function will be treated as Global function.
But you have to pass the this pointer to access class members. So not so good.
Best way:
The Below Example will explain the procedure.
class CTimer
{
void startTimer();
void doTimer();
};
int (* PFNCALLBACK)(void *);
int(CTimer::*PFNMEMBERCALLBACK)();
PFNCALLBACK functionCast( PFNMEMBERCALLBACK pMemberCallback)
{
union
{
PFNCALLBACK m_callback;
PFNMEMBERCALLBACK m_member;
} a;
a.m_member = pMemberCallback;
return a.m_callback;
}
void CTimer::startTimer()
{
ISHELL_SetTimer( pIShell, timeInterval, functionCast(&CTimer::doTImer), NULL);
}
So what you say.
Sunday, December 03, 2006
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment