Pass callback function if it is a class member
| DmitryG (3) | |||||||
| 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
.cpp
Sorting:
I receive error: error C2440: '=' : cannot convert from 'int (__stdcall CUsersView::* )(LPARAM,LPARAM,LPARAM)' to 'PFNTVCOMPARE' There is no context in which this conversion is possible PFNTVCOMPARE is:
typedef int (CALLBACK *PFNTVCOMPARE)(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort);I suppose I pass function pointer incorrectly... Thanks! | |||||||
| Duoas (1458) | |||
| Non-static object methods cannot be used directly as callback functions. Here are a couple of pages that deal with creating callback adaptors. http://www.partow.net/programming/templatecallback/index.html http://www.myelin.co.nz/notes/callbacks/cpp-interface-callbacks.html Good luck! | |||
| Zaita (1450) | |||
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. | |||
This topic is archived - New replies not allowed.
