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

  • From: "Yashasvi A.C." <yashasviac@xxxxxxxxx>
  • To: haiku-development@xxxxxxxxxxxxx
  • Date: Sun, 24 May 2009 04:48:04 +1200


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:
BMessage* msg = new BMessage();
BMessageFilter(B_ANY_DELIVERY, B_ANY_SOURCE, message_print_hook(msg, this,

This gives an error saying "undefined reference to
message_print_hook(BMessage*, BHandler*, BMessageFilter*)".
So, what parameters do I need to pass in to the function (if thats what the
problem is)?

Thanks for the help,

On Tue, May 19, 2009 at 2:15 AM, Rene Gollent <anevilyak@xxxxxxxxx> wrote:

> On Mon, May 18, 2009 at 9:00 AM, Yashasvi A.C. <yashasviac@xxxxxxxxx>
> wrote:
> > I am new to this process and dont really understand how it works. So,
> what
> > is the best way of using BMessageFilter?
> > I have added the following code snippet to the "Help Window" that pops
> up.
> No need to override MessageReceived in order to use the filter, just
> do AddFilter(fMessageFilter); and it will implicitly be called on
> message receipt. One of BMessageFilter's means of construction is by
> passing it a filter hook function. In this form your code would look
> something like:
> filter_result message_print_hook(BMessage *msg, BHandler *handler,
> BMessageFilter *filter)
> {
> printf("Received message for handler %s\n", handler->Name());
> msg->PrintToStream();
> }
> And then construct your filter as: fMessageFilter = new
> BMessageFilter(B_ANY_DELIVERY, B_ANY_SOURCE, message_print_hook);
> AddFilter(fMessageFilter);
> Regards,
> Rene

Other related posts: