M
maverik
Hi.
I have class ListView
ListView.h:
class ListView {
...
typedef void (*ListViewCallback)(ListViewItem& );
...
void SetMouseButtonUpCb(ListViewCallback );
...
};
and some other class MyClass:
MyClass.h:
#include "ListView.h"
class MyClass {
...
ListView m_listView;
...
};
MyClass.cpp:
#include "ListView.h"
void
MyClass::Foo() {
m_listView.SetMouseButtonUpCb(&GDoClick); // That's ok
m_listView.SetMouseButtonUpCb(&MyClass:oClick); // Error
// 'ListView::SetMouseButtonUpCb' : cannot convert parameter 1 from
'void (__thiscall MyClass::*) (ListViewItem &)' to
'ListView::ListViewCallback'
}
void
MyClass:oClick(ListViewItem& item) {
...
}
void
GDoClick(ListViewItem& item) {
...
}
Where DoClick(ListViewItem& ) is member of MyClass and GDoClick
(ListViewItem& ) is a global function.
As you can see registring global function GDoClick as a callback is
OK, but registring a member of the class produce an error.
Unfortunately, I have some restrictions:
1. I cannot change callback definition. For example, I can't write
typedef void (*MyCLass::ListViewCallback)(ListViewItem& );
2. I cannot use global function as a callback. Can't do this:
m_listView.SetMouseButtonUpCb(&GDoClick);
Question: is there a way in that i can do this (can register class
method as a callback):
m_listView.SetMouseButtonUpCb(&MyClass:oClick);
Thanks.
I have class ListView
ListView.h:
class ListView {
...
typedef void (*ListViewCallback)(ListViewItem& );
...
void SetMouseButtonUpCb(ListViewCallback );
...
};
and some other class MyClass:
MyClass.h:
#include "ListView.h"
class MyClass {
...
ListView m_listView;
...
};
MyClass.cpp:
#include "ListView.h"
void
MyClass::Foo() {
m_listView.SetMouseButtonUpCb(&GDoClick); // That's ok
m_listView.SetMouseButtonUpCb(&MyClass:oClick); // Error
// 'ListView::SetMouseButtonUpCb' : cannot convert parameter 1 from
'void (__thiscall MyClass::*) (ListViewItem &)' to
'ListView::ListViewCallback'
}
void
MyClass:oClick(ListViewItem& item) {
...
}
void
GDoClick(ListViewItem& item) {
...
}
Where DoClick(ListViewItem& ) is member of MyClass and GDoClick
(ListViewItem& ) is a global function.
As you can see registring global function GDoClick as a callback is
OK, but registring a member of the class produce an error.
Unfortunately, I have some restrictions:
1. I cannot change callback definition. For example, I can't write
typedef void (*MyCLass::ListViewCallback)(ListViewItem& );
2. I cannot use global function as a callback. Can't do this:
m_listView.SetMouseButtonUpCb(&GDoClick);
Question: is there a way in that i can do this (can register class
method as a callback):
m_listView.SetMouseButtonUpCb(&MyClass:oClick);
Thanks.