Overriding the Handler Method

From RAD Studio
Jump to: navigation, search

Go Up to Changing Message Handling

To change the way a component handles a particular message, you override the message-handling method for that message. If the component does not already handle the particular message, you need to declare a new message-handling method.

To override a message-handling method, you declare a new method in your component with the same message index as the method it overrides. Do not use the override directive; you must use the message directive and a matching message index.

Note that the name of the method and the type of the single var parameter do not have to match the overridden method. Only the message index is significant. For clarity, however, it is best to follow the convention of naming message-handling methods after the messages they handle.

  MESSAGE_HANDLER(parameter1, parameter2, parameter3)
  • parameter1 is the message index as Windows defines it.
  • parameter2 is the message structure type.
  • parameter3 is the name of the message method.

You can include as many MESSAGE_HANDLER macros as you want between the BEGIN_MESSAGE_MAP and END_MESSAGE_MAP macros.

See Also