Hi All, I am not vry clear with the usage of callback function for Event handling. What i understand is that, the Application registers a callback function. This callback func has the code to handle the diffent events that are expected. When one of these events hapen, the Callbak func gets called. But what i want to understand is that, how does the callback function gets to know that it has to get executed? If the same event is handled by two diff functons, then what should happen.. Plz send me links or pointers wher i can study mor about the same topic. Thanks in advance.
When the function is called means the function executes and the callee who provide the function callback knows when to call the function call back.
Thankx for the quick responce Shabbir. But m still not clear. int (*function_cb) (arg1, arg2) return_val = caller_function (arg11,arg22,(int)function_cb); In the above case, when will function_cb get called?
function_cb is a function pointer and it will not get call but depending on the situation the callee will call the function (pointed by the function pointer) I will give you an example. 1. Say you have a function which updates the progress bar for some copy of files operation. 2. When any chunk of file is copied successfully you call the function. 3. Function does it job to update the progress bar.
ok.. Could u give me an example in code form, which handles some event by calling a callback function.
Refer to the API CopyFileEx where you can specify your call back function in the third parameter and you will see how the call back function of yours is called
hello priya, do read this links http://www.codeguru.com/Cpp/Cpp/cpp_mfc/callbacks/article.php/c10557/ http://www.newty.de/fpt/callback.html with regards kaustubh