Positioning components on the design-time form

I'm creating a few component instances during initialization of a Scripter based IDE-like application, and adding them to the Scripter design-time form with InsertComponent like this

  var F := TcrackTIDEScriptForm(IDEEngine1.Files.FindByFormName('Form2').Form);
  var T := TnxTable.Create(nil);
  T.Name := 'nxTable1';
  F.InsertComponent(T);

However, that makes all the components end up on top of each other in the upper left corner, which is awkward for the user. Is there any way to move the components programmatically before opening the design-time form?

You could try something like this:

var
  DInfo: Longint;
begin
...
  F.InsertComponent(T);
  LongRec(DInfo).Lo := LeftPosition;
  LongRec(DInfo).Hi := TopPosition;
  T.Component.DesignInfo := DInfo;

Thanks, that works. For anyone else following, that last line should be

F.Components[idx].DesignInfo := DInfo;

Where idx is the index of the inserted components.

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.