hello,

How can I encapsulate a callback function in a C++ class:
// customised telephony class
class CTelMan
{
...
// to initialise line and call
void Initl();
// actually make the call
void MakeCall(LPCTSTR aPhoneNum);
// TODO: callback from line, call request completed
// ? should be static ?
void HandleCallEventL( DWORD hDevice,
DWORD dwMsg,
DWORD dwCallbackInstance,
DWORD dwParam1,
DWORD dwParam2,
DWORD dwParam3
);
....
};

void CTelMan::MakeCall(LPCTSTR aPhoneNum)
{
....
lineOpen(...)
}

void CTelMan::HandleCallEventL( DWORD hDevice, DWORD dwMsg,
DWORD dwCallbackInstance,
DWORD dwParam1,
DWORD dwParam2,
DWORD dwParam3
)
{
// ? how to use the following callback function encapsulated in a class ?
? lineCallbackFunc( hDevice, dwMsg, dwCallbackInstance, dwParam1,
dwParam2, dwParam3)
}
best regards,
Olive

Re: how to encapsulate callback function in a C++ class by andrej

andrej
Tue Sep 19 13:26:25 CDT 2006

Yes, make the class member function static
and pass it like this to the TAPI function:

lineXX( &CTelMan::HandleCallEventL )

Olive schrieb:
> hello,
>
> How can I encapsulate a callback function in a C++ class:
> // customised telephony class
> class CTelMan
> {
> ...
> // to initialise line and call
> void Initl();
> // actually make the call
> void MakeCall(LPCTSTR aPhoneNum);
> // TODO: callback from line, call request completed
> // ? should be static ?
> void HandleCallEventL( DWORD hDevice,
> DWORD dwMsg,
> DWORD dwCallbackInstance,
> DWORD dwParam1,
> DWORD dwParam2,
> DWORD dwParam3
> );
> ....
> };
>
> void CTelMan::MakeCall(LPCTSTR aPhoneNum)
> {
> ....
> lineOpen(...)
> }
>
> void CTelMan::HandleCallEventL( DWORD hDevice, DWORD dwMsg,
> DWORD dwCallbackInstance,
> DWORD dwParam1,
> DWORD dwParam2,
> DWORD dwParam3
> )
> {
> // ? how to use the following callback function encapsulated in a class ?
> ? lineCallbackFunc( hDevice, dwMsg, dwCallbackInstance, dwParam1,
> dwParam2, dwParam3)
> }
> best regards,
> Olive