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

  • From: "Yashasvi A.C." <yashasviac@xxxxxxxxx>
  • To: haiku-development@xxxxxxxxxxxxx
  • Date: Wed, 3 Jun 2009 01:10:37 +1200

Yup, it prints out the 3 letter message. But, what header were you
mentioning here? Did you mean Message.h? There is nothing about the message
constant in the header file.

Thanks,
Yash

On Sat, May 30, 2009 at 6:16 AM, <pete.goodeve@xxxxxxxxxxxx> wrote:

> On Fri, May 29, 2009 at 02:39:25PM -0300, André Braga wrote:
> > Em 29/05/2009, às 09:47, "Yashasvi A.C." <yashasviac@xxxxxxxxx>
> > escreveu:
> > >Hey guys,
> > >
> > >Thanks for the help. I figured it out. :) Was a problem with the
> > >namespace of the function.
> > >When I try to print out message->what, it prints out a number like
> > >1400700986 or something similar of that sort. Is there any way where I
> > > can  access the name of the message, like MOUSE_DOWN or CLICK or
> > >something like that? Under BMessage, only "what" is listed as a data
> > >member.
> >
> > I'm not an expert at all, but I can tell you that B_MOUSE_DOWN and the
> > like are symbolic constants that are represented by 32 bit integes,
> > not strings; so you won't really find pretty names when you dump those
> > BMessages. Unless you're using a smarter debugger than stock GDB,
> > you'll have to do the translation to the constant of interest
> > manually. See the headers that you're including for these message
> > types: they will tell you the correspondence. Beware of endianness and
> > all.
> >
> > Sometimes it helps to print the "what" field as a hex number, and see
> > if a 4-letter ASCII string (possibly inverted, i.e. byteswapped) comes
> > out of it. Some kits and apps use those 4-letters-ish forms. You might
> > want instead to use some bitmasks and shifts and typecasts to extract
> > and print those letters directly.
>
> A simple trick I sometimes use is to print that 32-bit value as a
> string.  It gets byte-reversed, but you see the characters the designer
> originally chose for the constant, which is often helpful.  And you can
> search the headers for those four characters to find the constant's
> actual name.
>
> Like this:
>           printf("Message id: %.4s\n", &msg->what);
>
> Note the period and the '&'!
>
> HTH
>                -- Pete --
>
>
>

Other related posts: