Javier Tarí 23 Posted November 25, 2020 Short: At design time, How can I get the IDesigner interface for a given form? Long: I have a VCL DBGrid-kind component developed for D5 and working fine all the way up to D10.4.1, except for one thing At design time, when I clic on a column header, it should select on the Object Inspector the TCollectionItem descendant for that column In D5, it was as easy as finding the form owning the DBGrid-kind, and then using FDesigner.SelectComponent(TheColumn); But now the form has IDesigner: IDesignFormHook, so I don't know how to do a SelectComponent Thanks in advance Share this post Link to post
David Hoyle 68 Posted November 25, 2020 I'm not sure I understand correctly what you are trying to do here but the Open Tools API can provide you access to the IDesigner from INTAFormEditor.GetFormDesigner. You can get the INTAFormEditor by querying the IOTAModule interface for the form. 1 Share this post Link to post
Javier Tarí 23 Posted November 25, 2020 1 hour ago, David Hoyle said: I'm not sure I understand correctly what you are trying to do here but the Open Tools API can provide you access to the IDesigner from INTAFormEditor.GetFormDesigner. You can get the INTAFormEditor by querying the IOTAModule interface for the form. Don't thik I understood you.. Do you mean something as this? ((Form as IOTAmodule) as INTAFormEditor).GetFormDesigner Share this post Link to post
David Hoyle 68 Posted November 25, 2020 No. What is the context under which you are trying to do what you are attempting. To do what I've described you need to write an Open Tools API BPL or DLL and add it to the IDE. This will then give you access to the designer once you have an IOTAModule reference to your form. Share this post Link to post
Javier Tarí 23 Posted November 25, 2020 Thank you; finally understood it Ofcourse, it is a BPL registering the components and some property editors, all of them working Following your advice, I've solved it this way: var ModuleServices: IOTAModuleServices; FFormEditor: IOTAFormEditor; NTAFormEditor: INTAFormEditor; FormModule: IOTAModule; aFormDesigner: IDesigner; begin aFormDesigner:=nil; ModuleServices := BorlandIDEServices as IOTAModuleServices; if Assigned(ModuleServices) then begin FormModule := ModuleServices.FindFormModule(Self.Owner.Name); if assigned(FormModule) then begin FFormEditor := FormModule.GetModuleFileEditor(FormModule.GetModuleFileCount - 1) as IOTAFormEditor; if Supports(FFormEditor, INTAFormEditor, NTAFormEditor) then aFormDesigner:=NTAFormEditor.GetFormDesigner; end; end; //Now you just select the column, i.e.: if Assigned(aFormDesigner) then aFormDesigner.SelectComponent(Column(ACol)) end; Next one also works, but I'm not sure if it should work, so will keep the first one var aFormDesigner: IDesigner; aForm: TCustomForm; begin AForm:=GetParentForm(Self); If not Supports(aForm.Designer,IDesigner,aFormDesigner) Then aFormDesigner:=nil; if Assigned(aFormDesigner) then begin aFormDesigner.SelectComponent(Column(ACol)); end; Share this post Link to post
balabuev 102 Posted January 7, 2021 It can be done much simpler: 1) Use FindRootDesigner function defined in Classes.pas. 2) Just cast the return value to IDesigner. dsnr := FindRootDesigner(AComponent) as IDesigner; 1 Share this post Link to post
Javier Tarí 23 Posted January 7, 2021 Works perfect; thank you very much Share this post Link to post