IT lexicon › Programming › BMessage

BMessage

Programming På svenska → Updated: 2026-11-09

The message object holding the BeOS and Haiku API together: a type code plus any number of named, typed fields.

BeOS gave every window its own thread, and threads that don't share memory without locks need a way to talk. The answer was BMessage. A message carries a 32-bit what field, usually written as a four-character constant like 'SAVE', plus named fields holding strings, numbers, rectangles or entire nested messages. It's addressed to a BHandler, and a BLooper — every BWindow is one — receives it on its own thread and dispatches it.

The same object handles drag and drop, the clipboard, settings files and the system's scripting interface, since a BMessage can be flattened to bytes and unflattened again. That makes the API unusually coherent. It also means a BeOS programmer asked "how do I get data from here to there?" has essentially one answer, every time.

← Back to the lexicon