RAD Studio
ContentsIndex
PreviousUpNext
Creating a Unit File

A unit is a separately compiled module of Delphi code. Delphi uses units for several purposes. Every form has its own unit, and most components (or groups of related components) have their own units as well. 

When you create a component, you either create a new unit for the component or add the new component to an existing unit.

To create a new unit for a component:

  1. Choose either:
    • FileNewUnit.
    • FileNewOther to display the New Items dialog box, select Delphi ProjectsDelphi FilesUnit, and choose OK. The IDE creates a new unit file and opens it in the Code editor.
  2. Save the file with a meaningful name.
  3. Derive the component class.

To open an existing unit:

  1. Choose FileOpen and select the source code unit to which you want to add your component.
    Note: When adding a component to an existing unit, make sure that the unit contains only component code. For example, adding component code to a unit that contains a form causes errors in the Tool palette.
  2. Derive the component class.

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!