On Nov 26, 1:36*pm, maverik <maverik.m...@gmail.com> wrote:
[snip]
> Question: is there a way in that i can do this (can register class
> method as a callback):
>
> * * m_listView.SetMouseButtonUpCb(&MyClass:
oClick);
This is an evergreen question in C++.
Think carefully what you are doing. A non-static
member function has not got an object to work in
until that object is created. And it can't find
that object unless you tell it how some way,
such as by using the object's name, or by calling
it through the object's address.
So your example
m_listView.SetMouseButtonUpCb(&MyClass:

oClick);
can't work without some modifications. Which
specific instance of MyClass do you want to
do the DoClick op?
If you are restricted in being unable to change the
signature of the callback then you have to use some
kind of "look up" strategy.
Someplace, you have to store the address of the
specific object you want. Then, you make a static
callback function that uses that address to forward
the request to the specific object, and returning
the appropriate data where it belongs.
In some callback systems you can pass the address
in as a parameter. In other cases you need some
way to save the object's address in your code,
and some way to pick the specific object you want.
If I recall, Microsoft windows lets you pass an
extra parameter to such callbacks. This might
not be acceptable as an address, but might be
ok as something that lets you look up an object
instance in a table, and get the address. The
system uses window handles or something.
Window handle or something, if I recall.
Socks