After reading this question, I was wondering if it is possible to modify TCustomEdit to check for the text width in a way that all of its descendants inherit the changes too?
After reading this question , I was wondering if it is possible to modify
Share
Most changes you make to
TCustomEditwill be inherited by descendants. That’s generally how inheritance works. It specifically depends on what kind of changes you make, though:If you edit StdCtrls.pas, then any changes you make will be inherited by any newly compiled code. One obstacle to this technique is getting Delphi accept the changes to your version of StdCtrls.pas without having to recompile other parts of the library that are difficult or impossible to recompile.
If you patch
TCustomEditmethods at run time (by the usual technique of overwriting the first few bytes of the method to direct control to a method of your own), then those changes will also be inherited by descendants.If you patch the
TCustomEditvirtual-method table, then some changes will be inherited, but not all. Virtual calls to your patched methods will use your custom version, but non-virtual calls will continue to use the original version. When a descendant usesinherited, the dispatch of that call to the inherited method is not virtual, so the VMT is not involved, and the descendant will end up calling the originalTCustomEditmethod.