[haiku-3rdparty-dev] Re: Capturing the "NTCH" message

  • From: Stephan Assmus <superstippi@xxxxxx>
  • To: haiku-3rdparty-dev@xxxxxxxxxxxxx
  • Date: Tue, 01 Dec 2009 09:47:27 +0100

Hi,

On 2009-12-01 at 01:34:25 [+0100], Yashasvi A.C. <yashasviac@xxxxxxxxx> 
wrote:
> Sorry, I should have been more specific. I did look at the BeBook and 
> found a suitable method "FindMessenger()".
> The code I use is:
> *BMessenger* myMessenger;
> message->FindMessenger("source", 3, myMessenger);
> 
> *Hopefully, I am correct about how to use this method. But my problem is
> then looking at what myMessenger contains. I went through the BeBook for 
> the BMessenger class but couldn't find anything similar to a toString() 
> method. So, my specific problem is if there is any way I can print out 
> the BMessenger class? If BMessenger itself prints out the word 
> "CheckBox1", that means its works perfect. Or, do I not understand 
> BMessengers correctly? Maybe I should be looking at myMessenger->Target() 
> and print out the BLooper or something?

First of all, you didn't understand how to extract a BMessenger. In the 
BeBook documentation for BMessage::FindMessenger(), there is a note:

"Important! In all cases except FindData() and FindString(), the data 
that's retrieved from the BMessage is copied into the reference argument; 
the caller is responsible for freeing the copied data. [...]"

So that means you have to do it like this:

BMessenger messenger;
message->FindMessenger("source", &messenger);

(Wy did you pass "3"? This should fail, since there is only one "source" 
field, you cannot extract the forth one. Always check the return codes!)

Second, you need to learn about scripting. If the BMessenger is inside a 
remote application, like I understand from your problem it will eventually 
be, then you need to extract the name via scripting. You cannot get a 
pointer to a BHandler object (which would have a Name() method that returns 
"CheckBox1" if it were an object inside your process). Instead, you need to 
use BMessage communication (scripting as outlined in the BeBook) with the 
remote team to get to the information of the name of the source BMessenger.

Please read the respective BeBook chapter on scripting.

<file:///boot/system/documentation/bebook/TheApplicationKit_Scripting.html>

Hint: There is B_GET_PROPERTY and B_NAME_SPECIFIER. ;-)

Best regards,
-Stephan

Other related posts: