I have a class CUsersView which is derived from CTreeView.
In OnUpdate function I want to sort root elements using custom callback function:
Callback function:
.h
1 2 3 4 5
class CUsersView : public CDNDTreeView
{
int CALLBACK UserGroupCompareProc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort);
...
}
.cpp
1 2 3 4 5
int CALLBACK
CUsersView::UserGroupCompareProc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort)
{
// Some code, including using of CUsersView instance members
}
error C2440: '=' : cannot convert from 'int (__stdcall CUsersView::* )(LPARAM,LPARAM,LPARAM)' to 'PFNTVCOMPARE'
There is no context in which this conversion is possible
Non-static object methods cannot be used directly as callback functions.
Don't confuse this statement with not being able to use function pointers to object methods. That is possible. Unfortunately, the interface your dealing with doesn't support it.