From RAD Studio API Documentation
Jump to: navigation, search


property OnMessage: TMessageEvent read FOnMessage write FOnMessage;


__property Vcl::Forms::TMessageEvent OnMessage = {read=FOnMessage, write=FOnMessage};


Type Visibility Source Unit Parent
event protected
Vcl.AppEvnts TCustomApplicationEvents


Occurs when the application receives a Windows message.

Use OnMessage to trap any or all Windows messages posted to all windows in the application. OnMessage occurs when an application receives a Windows message. OnMessage only receives messages that are posted to the message queue, not those sent directly with the Windows API SendMessage function.

An OnMessage event handler allows an application to respond to messages other than those declared in the events for TApplication. If the application doesn't have a specific handler for an incoming message, the message is dispatched to the window for which it was intended, and Windows handles the message.

Warning: Caution:Thousands of messages per second flow though this event. Be careful when coding the handler, because it can affect the performance of the entire application.

Tip: Call the CancelDispatch method from an OnMessage event handler to prevent the application from forwarding the event to any other application events objects.

See Also

Code Examples