Do you always clear the caption of a panel when you drop it on a form? Why? You can use component templates for that, and much more.
Do you know that you *can* change the height of the title/caption row in DBGrid by reaching for its "invisible" RowHeights property?
Delphi, VCL, OOP, Classes and a Day in a Developer lifeEven the birds can sing that Delphi's power is in the VCL - a set of visual components for rapid development of Windows applications in the Delphi language.
Without the VCL there's no Delphi.
The VCL is a hierarchy of classes designed to help you code faster and with more joy.
Here are some Delphi OOP specific tricks and goodies you should know of, to make your coding even more joyful :)
1. Accessing Protected Members of an ObjectMany Delphi components have useful properties and methods that are marked invisible ("protected") to the "user" of the component - that is you the Delphi developer. In Delphi OOP the protected data of a class is accessible to any method that appears in the same unit as the class.
A technique sometimes called the "Protected Hack" means deriving (subclassing) a component from an existing Delphi component with the only purpose or exposing the protected properties and methods.
Learn about the Protected Hack in Delphi
2. Fake Creating a New Delphi Control - IDE Component TemplatesThe Delphi IDE lets you derive new components from existing components by *not* deriving :))
You can create templates that are made up of one or more components. After arranging components on a form, setting their properties, and writing code for them, save them as a component template. Later, by selecting the template from the Component palette, you can place the preconfigured components on a form in a single step; all associated properties and event-handling code are added to your project at the same time.
Learn about Delphi Component Templates
3. Class Interceptors - Extend a Class - Don't Change the NameYou *can* create your own custom controls derived from the existing VCL set by creating a, so called, interceptor class that has the same name as the class being extended.
Find out about The Magic Behind type TButton = class(StdCtrls.TButton)
4. Class HelpersA class helper is a type that - when associated with another class - introduces additional method names and properties which may be used in the context of the associated class (or its descendants). Class helpers are a way to extend a class without using inheritance.
Sounds lovely? It is. Understanding Delphi Class (and Record) Helpers
5. Don't use any of Delphi componentsNo, I'm joking, use all. But. But, make sure you are prepared enough to be in a position to extend any class when you need it.
Why you should Build your Own VCL.
6. - But I'm not counting this one ;)We can derive a new component from any existing component, but the following are the most common ways to create components: modifying existing controls, creating windowed controls, creating graphic controls, subclassing Windows controls and creating nonvisual components. Visual or not, with or without property editor, from scratch...you name it.
It's never to late to start exploring Everything about creating custom components in Delphi. The ultimate source.