Implementing Message Methods The implementation of a message method can call the inherited message method, as in this example:
procedure TTextBox.WMChar(var Message: TWMChar);
begin
if Message.CharCode = Ord(#13) then
ProcessEnter
else
inherited;
end;
The inherited statement searches backward through the class hierarchy and invokes the first message method with
the same ID as the current method, automatically passing the message record to it. If no ancestor class implements
a message method for the given ID, inherited calls the
DefaultHandler
method originally defined in TObject.
The implementation of
DefaultHandler
in TObject simply returns without performing any actions. By
overriding
DefaultHandler
, a class can implement its own default handling of messages. On Win32, the
DefaultHandler
method for controls calls the Win32 API
DefWindowProc
.