Subclassing Windows Controls

From RAD Studio
Jump to: navigation, search

Go Up to Creating Components

In traditional Windows programming, you create custom controls by defining a new window class and registering it with Windows. The window class (which is similar to the objects or classes in object-oriented programming) contains information shared among instances of the same sort of control; you can base a new window class on an existing class, which is called subclassing. You then put your control in a dynamic-link library (DLL), much like the standard Windows controls, and provide an interface to it.

You can create a component "wrapper" around any existing window class. So if you already have a library of custom controls that you want to use in Delphi applications, you can create Delphi components that behave like your controls, and derive new controls from them just as you would with any other component.

For examples of the techniques used in subclassing Windows controls, see the components in the StdCtls unit that represent standard Windows controls, such as TEdit.