Overwriting interim classes lazarus / 21-General ---------------------------------------------------------------------- egsuh · 2022-04-11 02:53 Hi, I'm using interposing very usefully, as follows. Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i unit aqframe; interface uses   Classes, SysUtils, FileUtil, Forms, Controls, Grids, ComCtrls;  type   TStringGrid = class(Grids.TStringGrid)   protected      procedure KeyPress(var Key: Char); override;      procedure EditingDone; override;      procedure HeaderSizing(const IsColumn: Boolean;const AIndex, ASize: Integer); override;      procedure DoPrepareCanvas(aCol, aRow: Integer; aState: TGridDrawState); override;   public      procedure AdjustRowHeight(ARow: Integer);      procedure AdjustRowHeights;      procedure MoveDownRow;      procedure MoveUpRow;   end; //---------  unit rcfeditor_6; interface uses   Classes, SysUtils, FileUtil, Forms, Controls, ValEdit, ComCtrls, Menus,   ActnList, ExtCtrls, StdCtrls, Buttons, CodeFrame, aqframe;   // <== here I use aqframe   In this way, all following TStringGrid components act as I defined in aqframe unit. Now, I'd like to apply my default actions that I have overridden to TValueListEditor as well.  Of course it's simple, if I make a copy of my TStringGrid methods to TValueListEditor. But both TStringGrid and TValueListEditor are descendants of TCustomStringGrid, so overriding TCustomStringGrid will apply to both components. I can't think of a neat way to do this --- will class Helpers do this? Or is there anyway that I can override TCustomGrid's methods, so that both TStringGrid and TValueListEditor use overriding methods? ---------------------------------------------------------------------- Wallaby · 2022-04-11 04:43 AFAIK with a class helper you can add any methods to all TCustomStringGrid descendants, but it's not to possible to override methods. There is no way to override some methods of TCustomStringGrid and tell the compiler to use that class as ancestor for standard TStringGrid and TValueListEditor. You will have to duplicate code overriding methods in TStringGrid and TValueListEditor. Non-overrides can be made with class helpers if you want to minimise the code.