I have a very wired need where in I want to perform following in the IDEEngine:
Clear the content of the active Form. Here by clear content I mean remove all the controls from the active Form (.sfm) and also all the code from its associated module (.psc).
Want to give facility to user to borrow a form and its controls with their layout from withing the exe at run time. Here the user can copy the layout of say Purchase Order Form (which is actually designed in Delphi) with all the controls and with the same layout. This feature will help me give flexibility to users to replace the built in forms by creating their own forms visually and writing their own logic.
How can we Clear a Form and associated code and also add controls programmatically to an active Form in the IDEEngine?
With IDEEngine.Files you have access to all files in the project. Each TIDEProjectFile object in that collection has a Form property (of type TComponent, but represents the form instance) and Script property (of type TatScript).
Simply directly manipulate this objects, creating/destroying objects in the form, or changing Script.SourceCode property.