hi,

 

We have a class and it has a member function. When this function is called, it calls a Windows API. One of the argument of the windows API is a callback function. Naturally this callback function has to be a *non member* function. Is there any way by which I can pass a *member* function in the place of callback function. I heard about boost::bind, with bind is it possible?

 

Thanks,

  Lloyd

 



Since most Windows callback functions have a user passed in DWORD_PTR (or LPARAM) as one of the arguments, what I typically do is use a static member function of the class as the callback function and pass the “this” pointer as the DWORD_PTR. The static member function now has full access to the class and can either use member variables directly (via the passed in pointer) or forward the callback to a true member function.

 

 

-- Bill --