Loading...
 

PostMsg

PostMsg

Syntax
PostMsg(message[, DIRECT])

PostMsg(message)

parameters: Name of a message

Stack
Stack Position Description
Stack(In) Top any
Top 1 ...
Stack(Out) Top unchanged

This command causes the specified message to be triggered. In contrast to SendMsg, however, the message is only triggered after the events in the event queue up to the current time have been processed. Nevertheless, the recipients can see the stack as it looked like at the time of PostMsg. PostMsg leaves the stack unchanged.

This way of sending a message is used, for example, if circumstances occur in the course of the transaction that are to be checked again after processing, or to display user instructions with a time delay. If the current transaction was not explicitly ended beforehand, the message triggered by PostMsg works in the same transaction as the previous event.

Several PostMsg calls are processed in the same order in which the calls were made.

If exceptions occur or processing is stopped by cancel, the message is no longer triggered.

PostMsg(message, DIRECT)

parameters: Name of a message, flag DIRECT

Stack
Stack Position Description
Stack(In) Top a window object or module or vector of widgets/modules
Top 1 any
top 2 . . .
Stack(Out) Top -

If the DIRECT flag is specified, the message is only received from the objects (modules|widgets) specified as the first parameter. The call to PostMsg(..., DIRECT) takes the recipients from the stack and the recipients of the message see the stack as it was when PostMsg() was called (without recipients). This is also true for system events like SELECT and INITIALIZE. So it can happen that PostMsg(,DIRECT) calls messages with parameters on the stack, which are normally executed with an empty stack.

The recipient is passed on the stack (see instruction Widget or modules). If the receiver is a window object, the message is received by the window object and all children. If the receiver is a module, the message is received by the module and by all windows belonging to the module (and their children).

PostMsg(,DIRECT) behaves genasuo like SendMsg(,DIRECT) with the difference that the stack is not completely cleared and the message is executed with a delay.

Code example:

// At the start, send the message with the widget to response to! Button(CreateObjectBtn, 10, 10, 100, 8, T("Objekt erstellen", "Create object")) [ SELECT : Widget PostMsg(CREATE_OBJECT) // The command "Widget" puts the actual button on the stack. OBJECT_CREATED: -> newObject T("Objekt wurde erstellt!", "Object was created!") Attention(EndTXN, INFO) ] // Somewhere there is another module, which receives this message and does something with it: CREATE_OBJECT: // Receive the parameters from stack -> sender // Call the macro, which creates the object CreateObject // Send the message only to the sender! No broadcasting at all. // No other module will recognize this message! createdObject sender PostMsg(OBJECT_CREATED, DIRECT)

See also