Boost logo

Boost Users :

From: Aleksey Gurtovoy (agurtovoy_at_[hidden])
Date: 2005-05-10 19:31:46


Felipe Magno de Almeida writes:
> I would like to know if it is possible to generate a number of static
> functions that redirect to some other function inside the class,
> taking an object as void * and is casted to the object (that it knows
> which is), and be possible to take the address of such functions...

Sure. Wrapping (legacy) C interfaces along the above lines is probably
one of the most common basic application of C++ metaprogramming.

> well, i dont have a good english, so I will reexplain:
>
> For the ones that already are familiar with Win32 GUI:
> I must create a static function to be the DialogProc of a window, the
> problem is... I'm creating some property sheets to be used with one
> class, and I would like to make it automatic the redirection from the
> static function to some other method inside the class, that isnt
> static... and I would like to create a class, probably with CRTP to
> say to it to create the functions that would redirect to me, saying
> how much functions would that be, and make it creates the codes that
> gives to windows the static functions addresses and create the
> functions that would redirect....

Sounds like you are on the right track. You might want to check out
John Torjo's win32gui library (http://www.torjo.com/win32gui/), which
uses modern C++ techniques to build a set of convenient wrappers for
Win32 API along the same lines.

-- 
Aleksey Gurtovoy
MetaCommunications Engineering

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