Calling a Control's Message Handler Directly

From RAD Studio
Jump to: navigation, search

Go Up to Sending Messages


Sometimes there is only a single control that needs to respond to your message. If you know the control that should receive your message, the simplest and most straightforward way to send the message is to call the Perform method of the control.

There are two main reasons why you call the Perform method of a control:

  • You want to trigger the same response that the control makes to a standard Windows (or other) message. For example, when a grid control receives a keystroke message, it creates an inline edit control and then sends the keystroke message on to the edit control.
  • You may know what control you want to notify, but not know what type of control it is. Because you do not know the type of the target control, you cannot use any of its specialized methods, but all controls have message-handling capabilities so you can always send a message. If the control has a message handler for the message you send, it will respond appropriately. Otherwise, it will ignore the message you send and return 0.

To call the Perform method, you do not need to create a message record. You need only pass the message identifier, WParam, and LParam as parameters. Perform returns the message result.

See Also