in Delphi language, create a unit that uses interposer technique to add to every…
- User
in Delphi language, create a unit that uses interposer technique to add to every TComponent descendant a property of type TQryRecInfo named ORMRec and a property string named ORMRecField. Adjust the changes to the unit interposer_class: Additionaly, I want that keep TForm is an interposer of TForm that inherits from the interposed TComponent. Do the same approach to the other TComponents descendants Please review carefully before make the needed changes.
unit interposer_class;
interface
uses Vcl.Forms, Vcl.Controls, CommCtrl, Messages, sPanel, sEdit, sPageControl, System.Classes, AdvCGrid, Uni, pixel_classes, ORM_utils;
{$TYPEINFO ON}
type TForm = class(Vcl.Forms.TForm) protected procedure CreateParams(var Params: TCreateParams); override; public constructor Create(AOwner: TComponent); override; destructor Destroy; override; end;
TsPanel = class(sPanel.TsPanel) protected procedure CreateParams(var Params: TCreateParams); override; end;
TsEdit = class(sEdit.TsEdit) protected procedure CreateParams(var Params: TCreateParams); override; end;
TsPageControl = class(sPageControl.TsPageControl) protected procedure CreateParams(var Params: TCreateParams); override; private procedure TCMAdjustRect(var Msg: TMessage); message TCM_ADJUSTRECT; end;
TAdvColumnGrid = class(AdvCGrid.TAdvColumnGrid) private FByPassAF: TArray; function GetCellz(ACol, ARow: Integer): TZString; procedure SetCellz(ACol, ARow: Integer; const Value: TZString); function GetBypassAF(ACol: Integer): Boolean; procedure SetBypassAF(ACol: Integer; const Value: Boolean); protected procedure CreateParams(var Params: TCreateParams); override; public property Cellz[ACol, ARow: Integer]: TZString read GetCellz write SetCellz; property BypassAutoFit[ACol: Integer]: Boolean read GetBypassAF write SetBypassAF; published function CriaLinhaObjeto(MyObject: TObject): Integer; function CriaLinha: Integer; function GetColumnIndexByName(const nome: string): Integer; procedure SetBasicColumnConfig; end;
implementation
uses pixel_utils, System.Math, System.Types, Windows, System.SysUtils, TypInfo, Generics.Collections, Data.DB, Vcl.Graphics, ComCtrls, Vcl.Grids;
procedure TForm.CreateParams(var Params: TCreateParams); begin inherited CreateParams(Params); StrPCopy(Params.WinClassName, 'ZPro'); end;
constructor TForm.Create(AOwner: TComponent); begin inherited; end;
destructor TForm.Destroy; begin inherited; end;
procedure TsPanel.CreateParams(var Params: TCreateParams); begin inherited CreateParams(Params); StrPCopy(Params.WinClassName, 'Painel'); end;
procedure TsEdit.CreateParams(var Params: TCreateParams); begin inherited CreateParams(Params); StrPCopy(Params.WinClassName, 'Editor'); end;
procedure TsPageControl.CreateParams(var Params: TCreateParams); begin inherited CreateParams(Params); StrPCopy(Params.WinClassName, 'PagCtrl'); end;
- Assistant
- User
How this unit could be enhanced to override CreateParams to any TComponent, withou manually adding each one to the interposer unit?
- Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.