Create a design-time package for your component (if you do not already have one). In that package, create a class that implements the ISelectionEditor
interface (the easiest way is to derive from the TSelectionEditor
class), overriding its virtual RequiresUnits()
method to report any additional units you want to appear in the uses
clause of any Form/Frame/DataModule that uses your component. Then, have your package's Register()
function register that class by calling RegisterSelectionEditor()
(in addition to RegisterComponents()
).
Indy 10 does exactly this for its TIdTCPServer
, TIdCmdTCPClient
, and TIdUDPServer
components, to make sure the IdContext
and IdSocketHandle
units get added to uses
clauses. Look at the IdCoreSelectionEditors.pas
and IdRegisterCore.pas
units to see how Indy implements this.
Update: the IdCoreSelectionEditors.pas
and IdProtocolsSelectionEditors.pas
units were removed from Indy 10 in March 2014. All of the per-component SelectionEditor classes were replaced with a new single class implemented in the IdRegisterCore
unit itself. This new SelectionEditor class is registered for all Indy components, and it looks for all instances of any Indy component that has been placed at design-time, using RTTI of the data types of all parameters and return values for any assigned event handlers to know which units to report for inclusion in the uses
clause.