Changing component class at run-time on demand

This is easier as thought (thanks to Hallvard’s Blog – Hack#14: Changing the class of an object at run-time): procedure PatchInstanceClass(Instance: TObject; NewClass: TClass); type PClass = ^TClass; begin if Assigned(Instance) and Assigned(NewClass) and NewClass.InheritsFrom(Instance.ClassType) and (NewClass.InstanceSize = Instance.InstanceSize) then begin PClass(Instance)^ := NewClass; end; end; type TMyButton = class(TButton) public procedure Click; override; end; … Read more

How to avoid issues when embedding a TForm in another TForm?

I do this as well and I use the following routine to make it happen: procedure TMyForm.PlaceInsideContainer(Container: TWinControl); begin Parent := Container; Align := alClient; BorderIcons := []; BorderStyle := bsNone; ParentBackground := True; Show; end; I have no problems with this. The only difference that I could possibly imagine could be relevant is the … Read more