tags:

views:

207

answers:

2

The function header is defined below:

/**
 * \fn int fx_add_buddylist(const char* name, EventListener func, void *args)
 * \brief rename the group. 
 *
 * \param name The group name which you want to add.
 * \param func The send sms operate's callback function's address, and the operate         result will pass to this function.
 * \param args The send_sms operate's callback function's args. 
 *
 * \return 0 if fail immediately, or can get the result from func.
 */
FX_EXPORT int fx_add_buddylist(const char* name, EventListener func, void *args);


/**
* \defgroup cb_func Event CallBack Function
* @{
*/

/**
* \var typedef void (*EventListener) (int message, WPARAM wParam, LPARAM lParam, void*     args)
* brief the callback function of fetion event.
*
*
* \param message The fetion event type.
* \sa events
*/

typedef void (*EventListener) (int message, WPARAM wParam, LPARAM lParam, void* args);

/** @} end of cb_func */

I don't know how to use EventListener to get the result of fx_add_buddylist() (eg if i failed to add buddy or not).

+4  A: 

EventListener defines the interface of a function you have to write and pass as argument to fx_add_buddylist.

Do something like this:

void MyEventListener(int message, WPARAM wParam, LPARAM lParam, void* args)
{
    printf("Callback called!\n");
}

...
    fx_add_buddylist("SomeName", MyEventListener, NULL);
...

You can use the args argument to pass extra data you need in the callback function.

Hope this helps!

Regards,

Sebastiaan

Sebastiaan Megens
I shall give it a try. thx
A: 

Well, looks to me like you need to define your function and then hook it up using fx_add_buddylist(), something like:

void my_listener(int m, WPARAM w, LPARAM l, void *args) {
    .... do whatever you must
}

int res;
if (! (res = fx_add_buddylist("MyName", my_listener, args)) ) {
    fprintf (stderr, "Failed to add listener\n");
    exit (1);
}

I've no idea what the listener should do, in which context it is called, etc. Probably it's best if you get some sample code to read through. Incidentally this isn't a C++ question - you'd use a different paradigm there, this is plain-old C.

Karel Kubat