[Overview][Procedures and functions][Index] | Reference for unit 'LCLMessageGlue' (#lcl)

# DeliverMessage

Delivers a message (TLMessage) to the specified component, control or object.

## Declaration

Source position: lclmessageglue.pas line 34

`function DeliverMessage(`
`const Target: TObject;`
`var AMessage`
`):PtrInt;`

## Arguments

`Target` |  | Control or object where the message is delivered.
`AMessage` |  | TLMessage instance with the message type constant and result code used in the routine.

## Function result

Pointer to the result code from the TLMessage instance.

## Description

DeliverMessage ensures that the reference count for a TLCLComponent descendant in Target is maintained during message delivery. The reference count is incremented prior to message delivery, and decremented when the operation is completed.

If Target is a TControl descendant, the TLMessage instance is sent to the WindowProc method in the control. For TObject descendants, the message is sent using the Dispatch method in the class instance.

An exception which occurs during message delivery is forwarded to the HandleException method in the Application.

## See also

TLMessage |  |
Application |  | The TApplication singleton.
TApplication.HandleException |  | HandleException method for handling an exception; attempts to maintain program execution if possible, otherwise exits gracefully.
TLCLComponent |  | The base class for LCL components which have an associated widget.
TControl.WindowProc |  | The handler for all messages.
TObject.Dispatch