Boost logo

Boost Users :

Subject: Re: [Boost-users] Windows API callback, using boost::bind
From: Nat Linden (nat_at_[hidden])
Date: 2010-10-29 11:12:38


On Fri, Oct 29, 2010 at 2:42 AM, Lloyd <lloyd_at_[hidden]> wrote:

 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?
>

The key question is: does the Windows function also accept, and pass to your
callback, a void* data pointer so you can supply the callback function with
arbitrary data? (That idiom is quite common with classic C callbacks.)

If so, there are a number of different ways to get what you want here.
Please see the attached, which compiles and runs for me.





Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net