BMessage msg(MY_MESSAGE); BPoint startPt(10, 20); msg.AddPoint("startPoint", startPt); // later, in another part of the program... BMessage receivedMsg; while (somethingIsListening) { if (receivedMsg.what == MY_MESSAGE) { BPoint startPoint; if (receivedMsg.FindPoint("startPoint", &startPoint) == B_OK) { // do something with startPoint } } }
void MyView::MouseDown(BPoint where) { BMessage msg(MY_MESSAGE); msg.AddPoint("mousePos", where); be_app->PostMessage(&msg); }In this example, when the user clicks on a view in the program, a BMessage is created and a BPoint object containing the mouse's position is added to it under the name "mousePos". The message is then sent to the application using the be_app global variable's PostMessage() function, allowing other parts of the program to listen for this message and retrieve the mouse position. Package/ library: BeOS/Haiku Operating System