Tools API

Custom Forms

Open Tools API

Custom Forms


You can define a form class that publishes properties to the Object Inspector. This is called a custom form. Custom forms work a little differently from components. Defining a custom form is a four step process:
  1. Write your class. Inherit from TForm, TCustomForm, TDataModule, or indeed any window control class that inherits from TWinControl. The tricky part of writing your custom form class is writing the constructor.
  2. Write a custom module class to add menu items to Delphi's form editor. This is optional. You can use TCustomModule (in the DsgnIntf unit). Your custom module can also control what kinds of components the user is allowed to drop on the form.
  3. Write a form expert. The form expert creates an instance of your custom form at design time. Be sure to set the ancestor name to your custom form class name, and define the unit's source file correctly to use your custom form class and include its unit.
  4. Put your custom form class in a run-time package. Put your form expert and custom module in a design time package that uses your run-time package. Register your custom form by calling RegisterCustomModule. Install the design-time package in Delphi. Applications that use your custom form class will have the option to link statically (to the DCU file) or dynamically (to the package), unless of course you decide not to ship the DCU or DCP files.

Copyright © 1998 Tempest Software, Inc. All rights reserved.