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;


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.

Project Management Made Easy

Project Management Made Easy

What you need to know about… Project Management Made Easy! Project management consists of more than just a large building project and can encompass small projects as well. No matter what the size of your project, you need to have some sort of project management. How you manage your project has everything to do with its outcome.

Get My Free Ebook

Post a comment