Ah, this one is a little tough nut to crack, it seems...
Here's how the code should be, but which doesn't work:
Code:
Stuff::AddTrayIcon( _T(""), _T(""), _T("Countdown active!"), 0, 1000, new Callback(this, &CCountdownApp::TrayRightClick) );
Callback is a typedef:
Code:
typedef Stuff::CClassCallback<CCountdownApp*, void (CCountdownApp::*)()> Callback;
And AddTrayIcon is declared as:
Code:
void AddTrayIcon(const CString& strToolTip, const CString& strBalloonTip, const CString& strBalloonTitle, HICON hIcon, UINT nTimeOut, CTrayCallbacks Callbacks);
CTrayCallbacks has a constructor which takes a pointer to a CCallback class:
Code:
CTrayCallbacks(pp<CCallback> pCRButtonUp);
CClassCallback inherits from CCallback:
Code:
template<typename Class, typename Function> class CClassCallback: public CCallback
pp is a define for the memory manager class which has an overload for pointer type T*:
Code:
CMemoryManager(T* pNew);
So what should happen is that I create a new CClassCallback, which is implicitly cast to CCallback, which in turn is accepted by the CTrayCallbacks constructor.
Now, the above code doesn't seem to work.
However, this does:
Code:
Stuff::CCallback* pTest = new Callback(this, &CCountdownApp::TrayRightClick);
Stuff::CTrayCallbacks Test2(pTest);
...And this doesn't work:
Code:
Stuff::AddTrayIcon( _T(""), _T(""), _T("Countdown active!"), 0, 1000, pTest );
Which is basically the same as the Test2 line, is it not? This is why I'm confused as to why the implicit conversions won't take place when I pass the object directly to the function. I can pass Test2 perfectly fine.
This one also works fine:
Code:
Stuff::AddTrayIcon( _T(""), _T(""), _T("Countdown active!"), 0, 1000, (Stuff::CTrayCallbacks)pTest );
Ideas?