Using D10.2.3
function TForm1.GxOtaGetCurrentModule: IOTAModule;
var
ModuleServices: IOTAModuleServices;
begin
ModuleServices := BorlandIDEServices as IOTAModuleServices;
Assert(Assigned(ModuleServices));
Result := ModuleServices.CurrentModule;
end;
function TForm1.GxOtaGetFormEditorFromModule(const Module: IOTAModule): IOTAFormEditor;
var
i: Integer;
Editor: IOTAEditor;
FormEditor: IOTAFormEditor;
begin
Result := nil;
if not Assigned(Module) then
Exit;
for i := 0 to Module.GetModuleFileCount - 1 do
begin
Editor := GxOtaGetFileEditorForModule(Module, i);
if Supports(Editor, IOTAFormEditor, FormEditor) then
begin
Assert(not Assigned(Result));
Result := FormEditor;
// In order to assert our assumptions that only one form
// is ever associated with a module, do not call Break; here.
end;
end;
end;
function TForm1.GxOtaGetFileEditorForModule(Module: IOTAModule; Index: Integer): IOTAEditor;
begin
Assert(Assigned(Module));
Result := Module.GetModuleFileEditor(Index);
end;
procedure TForm1.Button2Click(Sender: TObject);
var
CurrentModule: IOTAModule;
CurrentForm: IOTAFormEditor;
lComponent: IOTAComponent;
begin
CurrentModule := GxOtaGetCurrentModule;
Assert(Assigned(CurrentModule));
CurrentForm := GxOtaGetFormEditorFromModule(CurrentModule);
if CurrentForm.GetSelCount > 0 then
lComponent := CurrentForm.GetSelComponent(0)
else
lComponent := CurrentForm.GetRootComponent;
if not lComponent.IsTControl then
begin
ShowMessage('The Component of Selected is not Container Control!');
exit;
end;
//CurrentForm.GetSelComponent(0).GetComponentType;
Label2.Caption:=lComponent.GetComponentType; <<<<< Tpanel or Tform
Label3.Caption:= CurrentForm.FileName; <<< file.dfm
// CurrentForm.CreateComponent(lComponent, 'TADOtable', 0, 0, 50, 50); <<<< This is OK
///THIS IS WHERE THE ERROR IS
CurrentForm.CreateComponent({CurrentForm.GetSelComponent(0)}lComponent, 'TLabel', 0, 0, 50, 50);<<<< This is an ERROR
end;
ERROR = Class TLabel is not applicable to this module
Any help?