Hi,
A few problems here. First of all, a delegate definition describes how you want to call the delegate, not the signature of the functions it’s bound to. If you want to bind 1 to a function ‘void MyFunction(uint8)’ (I’m guessing - you didn’t specify the definition of your function), it means you want the delegate to always pass 1 as that argument, which means that you pass zero arguments to the call.
Second, the bound variables needs to match the types of the delegate parameters precisely. So even though 1 is convertible to uint8, you need to cast it instead, like (uint8)1, which forces the type to be uint8 and the binding to be recognised.
So, I’m thinking your class wants to look something like this:
DECLARE_DELEGATE(RefreshOne);
class MyClass
{
public:
MyClass()
{
one.BindRaw(this, &MyClass::MyFunction, (uint8)1);
}
void MyFunction(uint8 Val)
{
// Whatever
}
void Invoke()
{
one.Execute(); // Will call this->MyFunction((uint8)1);
}
private:
RefreshOne one;
};
This is a simple example.
More generally, bound variables are applied to the end of delegated calls, so a more complex example might look something like this:
DECLARE_DELEGATE_TwoParams(Delegate, const TCHAR*, float);
struct MyClass
{
MyClass()
{
del.BindRaw(this, &MyClass::MyFunction, (uint8)1, 'x');
}
void MyFunction(const TCHAR* a, float b, uint8 c, char d)
{
// Whatever
}
void Invoke()
{
del.Execute(TEXT("Hello"), 3.14f); // Will call this->MyFunction(TEXT("Hello"), 3.14f, (uint8)1, 'x');
}
Delegate del;
};
Hope this helps.
Steve