Custom Component Development

Everything about creating custom components in Delphi. The ultimate source.

That's why you love Delphi!

I think we can all agree: components are essential elements of the Delphi environment. One of the most important features of Delphi is that we can use Delphi to create our own components.
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 name it.

Developing Delphi components isn't a simple task, it involves quite a bit of knowledge of the VCL. However, developing custom components is not an impossible task; writing components is just pure programming.

Articles, papers, tutorials
What follows is a list of articles that deal with custom component development in Delphi.

  • Accessing protected members of a component
    Many Delphi components have useful properties and methods that are marked invisible ("protected") to a Delphi developer. In this article you will find the workaround to this problem - thus enabling you to access a DBGrid's RowHeights property, for example.
  • Creating Custom Delphi Components - Inside and Out
    This tutorial will explain component writing to you, which should result in more code reuse. It will go over properties, events and methods, and will also explain how to install components. The final part of this tutorial is about Object-Oriented design.
  • Creating Custom Delphi Components, Part I
    This first part demonstrates some of the best approaches to building components, and at the same time provides tips on deciding on the best base class to inherit from, using virtual declarations, the complexities of overriding, and so on.
  • Creating Custom Delphi Components, Part II
    Quite often it is necessary to write components that perform more advanced functions. These components often need to either reference other components, have custom property data formats, or have a property that owns a list of values rather than a single value. We will explore various examples covering these very subjects, starting with the most simple.
  • Creating Custom Delphi Components, Part III
    This article is the final part of a three part article on components. Part one covered the basic creating of components, part two covered how to write advanced properties, how to write custom streaming for those properties, and sub-properties. This final part will cover property / component editors, how to write dedicated editors for your component / property, and how to write "hidden" components.

    More resources

    First, if you want more, consider buying a book on Developing custom components.
    Second, why not try locating an existing (with source perhaps) component you are looking for.
    Third, when you are 100% sure there is no such question on custom component development you can't answer...there will be something that you don't know. Everything you have to do is to ask a question on the Delphi Programming Forum and wait for answers.

    If you still need more samples .. try the second page ...

  • Articles, papers, tutorials
    Here is a list of articles that deal with custom component development in Delphi.

    • VCL Component Messages [RTF]
      Component Messages (CM_) are generated only by the VCL and are not reflected Windows Messages (WM_), as one may assume. In spite of that Component Notifications (CN_) are reflected Windows Messages. The idea behind it is, that Windows often sends messages to a parent window of a control instead of the control itself. The VCL simply converts (reflects) these messages to Component Notifications and then sends it to the control, for which the message originally was meant.
      • Delphi Component Building.
        In this article, read about every aspect of Delphi Component building. Design a TTicTacToe component and learn about: how to build our own components for Delphi, how to add properties, methods and custom events to them, how to wrap them around DLLs, how to install them, how to design a palette bitmap and write on-line help to support the component user.
      • Building SuperComponents in Delphi [download]
        SuperComponents, also known as aggregate or compound components, are collections of existing sub-components and their relationships combined into a single component. The collections are typically arranged inside a container parent component that manages the visual layout of the sub-components.