Ah, this one is a little tough nut to crack, it seems...
Here's how the code should be, but which doesn't work:
Callback is a typedef:Code:Stuff::AddTrayIcon( _T(""), _T(""), _T("Countdown active!"), 0, 1000, new Callback(this, &CCountdownApp::TrayRightClick) );
And AddTrayIcon is declared as:Code:typedef Stuff::CClassCallback<CCountdownApp*, void (CCountdownApp::*)()> Callback;
CTrayCallbacks has a constructor which takes a pointer to a CCallback class:Code:void AddTrayIcon(const CString& strToolTip, const CString& strBalloonTip, const CString& strBalloonTitle, HICON hIcon, UINT nTimeOut, CTrayCallbacks Callbacks);
CClassCallback inherits from CCallback:Code:CTrayCallbacks(pp<CCallback> pCRButtonUp);
pp is a define for the memory manager class which has an overload for pointer type T*:Code:template<typename Class, typename Function> class CClassCallback: public CCallback
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.Code:CMemoryManager(T* pNew);
Now, the above code doesn't seem to work.
However, this does:
...And this doesn't work:Code:Stuff::CCallback* pTest = new Callback(this, &CCountdownApp::TrayRightClick);
Stuff::CTrayCallbacks Test2(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.Code:Stuff::AddTrayIcon( _T(""), _T(""), _T("Countdown active!"), 0, 1000, pTest );
This one also works fine:
Ideas?Code:Stuff::AddTrayIcon( _T(""), _T(""), _T("Countdown active!"), 0, 1000, (Stuff::CTrayCallbacks)pTest );