CALLBACK, CALLBACK, CALLBACK? 
Author Message
 CALLBACK, CALLBACK, CALLBACK?

Hi.

I'm not good at VC++ programming.
I really want to know what in the world
the word CALLBACK means for in the context
of a function declaration?
Many thanks in advance.



Tue, 20 Aug 2002 03:00:00 GMT  
 CALLBACK, CALLBACK, CALLBACK?
If you check windef.h, you'll see that callback is defined differently
depending on compiler version and whether you're building for MAC, but
its just there to make sure that any function pointer passed to the
system uses the calling convention that the system expects.  

Compiling with browse info makes it real easy to research this sort of
thing. Just put the caret in the word "CALLBACK" and hit F12 and
you're looking at its definition.



Quote:
>Hi.

>I'm not good at VC++ programming.
>I really want to know what in the world
>the word CALLBACK means for in the context
>of a function declaration?
>Many thanks in advance.

Don Grasberger
Apply Occam's razor to Bill's beard.

(remove --- from address to e-mail)



Tue, 20 Aug 2002 03:00:00 GMT  
 CALLBACK, CALLBACK, CALLBACK?

Bonjour!

Quote:
>I'm not good at VC++ programming.
>I really want to know what in the world
>the word CALLBACK means for in the context
>of a function declaration?
>Many thanks in advance.

For your own function you don't need CALLBACK (AFAIK). It is used for
functions that Windows calls, SetWindowsHookEX - functions, i.g.

Robert

-----------------------------------------
Robert Fink

Germany



Tue, 20 Aug 2002 03:00:00 GMT  
 CALLBACK, CALLBACK, CALLBACK?


Quote:
> I really want to know what in the world
> the word CALLBACK means for in the context
> of a function declaration?

The specifics of how a CALLBACK is declared can be found
in your particular compiler's help files and header files.

The reason for a callback is, roughly, this.  Suppose you
have some item in your program (I'm deliberately avoiding
the term object) such as a window.  This window is, in some
ways, looked after by your operating system.  And in some
other ways, it is looked after by your program.  When the
OS needs to tell your program about something, it does this
by calling your program.  It does this through a CALLBACK
function.  The idea is, you give the OS a pointer to a function,
and that function has a particular signature.  Then the OS
calls that function when it thinks your program should take
action on something.

You can use the idea of a callback in many other contexts.
For example, if you had a program that calculated the integral
of a function, you might give it a callback to a function that
generated values of the function being integrated.  Then
the integration program could get the specific values it
needed instead of you having to generate all possible needed
values in advance.

In C++, the notion of a callback is somewhat changed.  You
probably don't use a pointer to a function, but rather a pointer
to an instance of a class.  Then through virtual functions and
polymorphism, the specific behaviour your window needs can
be provided.  You would have a derived class for your particular
kind of window, and it would be derived from some class that
provided an interface the OS knew.  The OS calls, say, the
function handleMessage(/* yada yada, message params */)
through the pointer, and then polymorphism sorts it out so it
goes to the version of handleMessage() in your particular
kind of window.

--
Dan Evens
Standard disclaimers etc. No spam please.
Just because nobody complains does not
mean that all parachutes are perfect.



Tue, 20 Aug 2002 03:00:00 GMT  
 CALLBACK, CALLBACK, CALLBACK?

Quote:

>the word CALLBACK means for in the context
>of a function declaration?

Well, you can look up the definition of CALLBACK in the headers, but
it really won't help you understand the concept. A callback is a
function that's going to be called by other code, usually the
operating system.

The operation of Windows itself is based upon callbacks : in a normal
SDK program, you specify a window callback procedure (a WndProc in the
terminology) which the system will call when it wants to "send" a
message.

This is all covered quite well in Charles Petzolds book on programming
windows.

--
Bob Moore [MVP]
http://www.mooremvp.freeserve.co.uk
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Due to an unreasonable amount of queries, I no
longer answer unsolicited email questions. Sorry,
no exceptions.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~



Tue, 20 Aug 2002 03:00:00 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Using a legacy C++ dll to callback into C#

2. COM Interface and Callbacks in .NET?

3. Callback from unmanaged class to managed class...

4. PrintDlgEx CallBack, how to pass lpcallback pointer?

5. help: textBox vs. StringBuilder in a callback function

6. Asynchronous CallBack strange behavior

7. Timer Callback doesn't have access to member data

8. callback in thread

9. remoting callbacks customization

10. managed callbacks

11. callbacks / delegates

 

 
Powered by phpBB® Forum Software