How to create new IOTAComponent on Delphi form

514 views Asked by At

I am trying to write Delphi Open Tools API tool for automatic generation and update of the components that are placed on the datamodule or on the form. I can already list all the components (each one is represented by the instance of (the class of) IOTAComponent) and modify their properties (setPropByName(...), getPropValueByName(...)). The question is - how to create new component - in Open Tools API code so that this component is added to the form of datamodule?

I am using IOTAModuleServices part of the API and I guess that is the right part for task at hand, isn't it?

1

There are 1 answers

0
Remy Lebeau On

You need to obtain the IOTAFormEditor interface for the Form/DataModule that you want to update, and then call its CreateComponent() method:

type
  IOTAFormEditor = interface(IOTAEditor)
    ['{F17A7BD2-E07D-11D1-AB0B-00C04FB16FB3}']
    ...
    function CreateComponent(const Container: IOTAComponent;
      const TypeName: string; X, Y, W, H: Integer): IOTAComponent;
    ...
  end;