I have this code:
typedef void (*DevRespPointer) (BlueDevice __gc*);
class InternalBlueManager : public CBtIf
{
public:
DevRespPointer DeviceRespondedDelegate;
InternalBlueManager(void)
{
}
~InternalBlueManager(void)
{
}
//Implementacion de Funciones Virtuales Heredadas
void OnDeviceResponded (BD_ADDR bda, DEV_CLASS devClass, BD_NAME bdName, BOOL bConnected)
{
if (DeviceRespondedDelegate!=0)
{
BlueDevice *bd = new BlueDevice(bda, devClass, bdName);
DeviceRespondedDelegate(bd);
}
}
};
/////////////////////////////////////////////
public __gc class BlueManager
{
private: //Miembros Privados
InternalBlueManager * blue;
public: // Funciones Publicas
BlueManager(void)
{
blue = new InternalBlueManager();
}
~BlueManager(void)
{
}
void SetDelegates()
{
blue->DeviceRespondedDelegate = OnDeviceResponded;
}
private: //Funciones Privadas
void OnDeviceResponded(BlueDevice __gc *device)
{
// Do Something;
}
};
If I compile this I get this error message on the red line:
error C2440: '=' : cannot convert from 'void (__clrcall BlueClasses::BlueManager::* )(BlueClasses::BlueDevice __gc *)' to 'BlueClasses:: DevRespPointer'
If I change the red line for
blue->DeviceRespondedDelegate = &OnDeviceResponded;
I get this error:
error C2276: '&' : illegal operation on bound member function expression
If I change it for
blue->DeviceRespondedDelegate = &BlueManager:: OnDeviceResponded;
I get this error:
error C3374: managed function 'BlueClasses::BlueManager:: OnDeviceResponded' requires argument list.
And if I change it for
blue->DeviceRespondedDelegate = &(BlueManager:: OnDeviceResponded);
I get this error again:
error C2276: '&' : illegal operation on bound member function expression.
I'm compiling it with Visual Studio 2003, Framework 1.1
I've tried all what I have seen on forums and manuals and it doesn't work. Somebody knows what am I doing wrond? and, how can I solve it?
Ferenck
typedef void (*DevRespPointer) (BlueDevice __gc*);
class InternalBlueManager : public CBtIf
{
public:
DevRespPointer DeviceRespondedDelegate;
InternalBlueManager(void)
{
}
~InternalBlueManager(void)
{
}
//Implementacion de Funciones Virtuales Heredadas
void OnDeviceResponded (BD_ADDR bda, DEV_CLASS devClass, BD_NAME bdName, BOOL bConnected)
{
if (DeviceRespondedDelegate!=0)
{
BlueDevice *bd = new BlueDevice(bda, devClass, bdName);
DeviceRespondedDelegate(bd);
}
}
};
/////////////////////////////////////////////
public __gc class BlueManager
{
private: //Miembros Privados
InternalBlueManager * blue;
public: // Funciones Publicas
BlueManager(void)
{
blue = new InternalBlueManager();
}
~BlueManager(void)
{
}
void SetDelegates()
{
blue->DeviceRespondedDelegate = OnDeviceResponded;
}
private: //Funciones Privadas
void OnDeviceResponded(BlueDevice __gc *device)
{
// Do Something;
}
};
If I compile this I get this error message on the red line:
error C2440: '=' : cannot convert from 'void (__clrcall BlueClasses::BlueManager::* )(BlueClasses::BlueDevice __gc *)' to 'BlueClasses:: DevRespPointer'
If I change the red line for
blue->DeviceRespondedDelegate = &OnDeviceResponded;
I get this error:
error C2276: '&' : illegal operation on bound member function expression
If I change it for
blue->DeviceRespondedDelegate = &BlueManager:: OnDeviceResponded;
I get this error:
error C3374: managed function 'BlueClasses::BlueManager:: OnDeviceResponded' requires argument list.
And if I change it for
blue->DeviceRespondedDelegate = &(BlueManager:: OnDeviceResponded);
I get this error again:
error C2276: '&' : illegal operation on bound member function expression.
I'm compiling it with Visual Studio 2003, Framework 1.1
I've tried all what I have seen on forums and manuals and it doesn't work. Somebody knows what am I doing wrond? and, how can I solve it?
Ferenck