Subj : Re: How to get address of CALLBACK function? To : borland.public.cpp.borlandcpp From : Ed Mulroy [TeamB] Date : Wed Mar 30 2005 04:27 pm It would have helped had you read and thought about what I wrote in my previous reply. From your message with capitalization added: > ... The Win32 Programmer's Reference says: > > dwCallback > > Address of a FIXED callback function ... TWaveChannel is a declared class type. A non-static, non-inline function has but one copy of its code in memory. There can be many instances of a given class. Each instance of a class contains its own set of data and the data of each class instance from which it inherits. The way C++ arranges for the single set of code associated with a normal member function is to provide a hidden first calling parameter, the 'this' pointer. By using that pointer the function operates on those items which are unique to this class instance. Windows has no idea what C++ is and provides no facilities for calling a non-static function with the hidden 'this' pointer. Therefore, were the address of a non-static class member function given to Windows as the address of a callback function it would then be called without the 'this' pointer with disastrous results. Stand alone and static class member functions have no hidden calling parameter so can be used as a calling parameter. .. Ed > Gasparics, Antal wrote in message > news:424aa0d5@newsgroups.borland.com... > > >>In the code shown the function TWaveChannel::waveOutProc is a >>non-static class member function. >> >>A callback function must either be a function not contained in a >>class or structure or a static member function of a class or >>structure. > Thx. However the problem is still the following. I have to tell the > windows the starting memory adrress of the function code, which will > be called back. The Win32 Programmer's Reference says: > > dwCallback > > Address of a fixed callback function, an event handle, a handle > to a > window, or the identifier of a thread to be called during > waveform-audio playback to process messages related to the > progress > of the playback. If no callback function is required, this value > can > be zero. For more information on the callback function, see > waveOutProc. > > So I need the address of my function. > > The "addressof" operator (&) can not be used here, or at least I can > not find how. I have static member function now, but the following > line can not be compiled: > > waveOutProcAddress = &WaveChannel.waveOutProc; > > The Error message: > E2034 Cannot convert 'void (__stdcall *)(void *,unsigned > int,unsigned long,unsigned long,unsigned long)' to 'unsigned long' .