If I run into this problem,
- First I try to inherit from the component or its ancestor CustomXXX and see if this fixes the problem. If this is not so,
- I go deeper, i.e. trying to intercept incoming messages. This can be done dynamically. If this turns out to be too deep, because the code that needs to be built on it is too extensive, or I still need to access elements that I cannot access,
- I'm trying to hack. One hack is copying a component and dependent code to a new block with a different name, renaming the component and changing what needs to be changed.
- Sometimes I only need to repeat one or two methods to make my new behavior possible.
Never forget to give the device a different name, and the component a different name (possibly inherited from the original component or one of its ancestors, so they remain in the same hierarchy). Never change the source, then recompile the VCL. This is a nightmare to service.
I am not a fan of intermediary classes, that is, classes that receive the same name, but differ from the original classes, inheriting from the original. Their functionality depends on the order of inclusion in the uses clause, and this seems to me superfluous. I can not recommend this.
But what I do is highly dependent on the problem. I do not think that it is possible (or should) give full advice that covers all situations.
But my main advice: do not change the original units , always put the new code in a new block and use the new class name. Thus, the original and modified versions can coexist peacefully, also in the IDE.
source share