Home

Tools API

Options

Open Tools API

Introduction
Services

Options

Wizards
Messages
Notifiers
Creators
Editors
Debugger
Examples
Custom Forms

Home

The new Tools API lets you examine and modify a project's options and environment options. Each option is identified by name, e.g., DesigntimeOnly, and has a type and value. The type is usually Integer, Enumeration, or String. If the type is Enumeration, you don't get to see the enumerated literals, only the ordinal values. You need to know what the values mean, e.g., 0 for False, and 1 for True. You can cast the ordinal value to the desired type, and when setting a value, you can use an enumerated literal. Delphi will automatically grab the ordinal value.

Every project has the same list of options, which is the union of all possible project options, including C++ projects, packages, applications, and libraries. You need to determine which options are meaningful for your project.

Given a project interface, use ProjectOptions to obtain the options interface, IOTAProjectOptions. You can, for example, set project options for a newly created project after calling CreateModule. Cast the IOTAModule interface that CreateModule returns to IOTAProject.

To get the environment options, use IOTAServices and call GetEnvironmentOptions.

Once you have the options interface, they work the same way for environment or project options.

IOTAOptions

An options interface lets you get or set any option. Call GetOptionNames to get an array of option names. Each option name also has its type, as TTypeKind value. To get or set an option value, use the Values property, indexed by option name. The value is a Variant, so you should just use the proper value and type, e.g., a string, an integer, etc.

If you get an option type wrong, Delphi raises an invariant type error. If you specify an invalid option, Delphi ignores it.

For example, if you write a project wizard that creates a package, but you want the package to be design-time only, do the following:

procedure TMyPackageWizard.Execute;
var
  Project: IOTAProject;
  Options: IOTAProjectOptions;
begin
  with BorlandIDEServices as IOTAModuleServices do
    Project := CreateModule(TMyCreator.Create)
      as IOTAProject;
  Options := Project.ProjectOptions;
  Options.Values['DesigntimeOnly'] := True;
  Options.Values['RuntimeOnly'] := False;
end;

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