[haiku-development] Re: Intercepting messages between the applications and App. Server

Hi Yashasvi,

Yashasvi A.C. schrieb:
Hey,

I used the given code extract but an error saying "no matching function call
to BMessageFilter (message_delivery, message_source, {unkown type})"
occurred. Then, I realised that perhaps it was supposed to be
message_print_hook() function call i.e. with the brackets, while
initialising fMessageFilter. I am not sure what parameters need to be passed
to message_print_hook().

My code kinda looks like:
<code>
BMessage* msg = new BMessage();
BMessageFilter(B_ANY_DELIVERY, B_ANY_SOURCE, message_print_hook(msg, this,
fMessageFilter));
</code>

it could look like this:

static filter_result
message_print_hook(BMessage* msg, BHandler** target,
    BMessageFilter* filter)
{
    // do something

    return B_DISPATCH_MESSAGE;
}

MyView::MyView()
    : BView(/*init parent*/)
{
    BMessageFilter* filter = new BMessageFilter(B_ANY_DELIVERY,
        B_ANY_SOURCE, &message_print_hook);
    AddFilter(filter);
}

You should probably read up on how to use function pointers.

http://www.newty.de/fpt/index.html

http://www.haiku-os.org/legacy-docs/bebook/BMessageFilter.html
http://www.haiku-os.org/legacy-docs/bebook/BMessageFilter.html#filter_hook


Regards,
Karsten

Other related posts: