If I want to replace a VCL component TXxx
should I base my component on TXxx
or TCustomXxx
?
I am looking to make drop-in replacements for various text-editing components (TEdit
, TMemo
, etc.) to have WM_PASTE handlers to sanitize inputs to a back-end that is very picky about what it will accept (basically only 7-bit ASCII printable glyphs, spaces, and CR/LF pairs... even tab characters are not acceptable to it). These new components have to go into an existing application, and I want to not do anything I don't absolutely have to in order to make them work exactly the way the old ones did, except for the non-default paste behavior.
I've done one based on TMemo
and it seems to work, but somehow or other I have the impression that the recommended approach would be to use TCustomMemo
. Is there something I am missing?
By convention, the difference between TSomething and TCustomSomething is that the latter has no or very few published properties so that you can pick which ones to publish yourself. Otherwise there should not be any difference.
The way I've always understood the concept of having TSomething
and TCustomSomething
is when you create your own inheritance of, let's say TButton
to your own called TMyBytton
. Suppose you want to hide a property, such as Caption
(assuming you might not want text). With the TButton
, you cannot hide this property. But using a TCustomButton
, you can publish which ever properties you want to be visible in the object inspector, and exclude those which you do not want to see. Once a property has been published, it cannot be un-published in further inherited classes.
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