callback functions
the most common call back funtion is the windows messenger handler function. you pass the address of the function that you wrote to windows and windows calls that function back as it needs to. a simple windows messenger handler looks something like this.
windows calls this function whenever there is a message in the queue and handles the message depending on your switch case statements. any messages that you did not handle you can pass to the default message handler function.
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam){ switch(message) { case WM_DESTROY: PostQuitMessage(0); return 0; case WM_SIZE: GetWindowRect(hWnd, &windowRect); return 0; default: return DefWindowProc(hWnd, message, wParam, lParam); }} // WndProc
windows calls this function whenever there is a message in the queue and handles the message depending on your switch case statements. any messages that you did not handle you can pass to the default message handler function.
Note that callbacks are a C thing; avoid using them in C++, except to maintain compatibility with C interfaces (such as the windows API). A better solution in C++ is virtual subclasses used as interfaces; check any decent OOP textbook for examples of this.
How appropriate. You fight like a cow.
How appropriate. You fight like a cow.
http://www.function-pointer.org
it is a nice site and has helped me with my callback problem
take a look.
http://www.function-pointer.org/CCPP/callback/callback.html#chapter3
Lazzar
if god gave us the source code, we could change the world!
it is a nice site and has helped me with my callback problem
take a look.
http://www.function-pointer.org/CCPP/callback/callback.html#chapter3
Lazzar
if god gave us the source code, we could change the world!
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement