If I add a TXMLDocument
to a form from the IDE, the units Xml.XMLDoc, Xml.xmldom, Xml.XMLIntf, Xml.Win.msxmldom
are automatically added (on save/compile), how does the IDE know to add these units. I understand why/how XMLDoc
is added (it contains TXMLDocument
) but what about the others.
Additionally if I change the DOMVendor from MSXML to ADOM XML v4, Xml.adomxmldom
is automatically added (on the next compile). At this point I can remove Xml.Win.msxmldom
without it being added back automatically. How does the IDE know this based on a component property?
I have two reasons for asking this question, firstly curiosity, but secondly I'm cleaning up the uses section of a large number of units (hundreds). The project uses DevExpress, and it adds heaps of additional files to the uses - for instance add a TcxSpinEdit
then cxSpinEdit, cxGraphics, cxControls, cxLookAndFeels, cxLookAndFeelPainters, cxContainer, cxEdit, cxTextEdit, cxMaskEdit
are added. I'm wanting to minimize the uses clause where controls have been removed from forms (but their units remain in the uses) and thus need to understand the process whereby they are added better.
Components can arrange that their presence in the designer forces specific units to be added to the unit's uses clause. They do so by calling RegisterSelectionEditor
to register their TSelectionEditor
sub-classes. These sub-classes override TSelectionEditor.RequiresUnits
and there specify the units which must be added.
For instance:
uses
DesignEditors;
....
type
TMySelectionEditor = class(TSelectionEditor)
public
procedure RequiresUnits(Proc: TGetStrProc); override;
end;
procedure TMySelectionEditor.RequiresUnits(Proc: TGetStrProc);
begin
Proc('MyUnit');
end;
procedure Register;
begin
RegisterSelectionEditor(TMyComponent, TMySelectionEditor);
end;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With