Creating component with embedded TShape lazarus / 31-LCL ---------------------------------------------------------------------- vix · 2014-08-12 19:09 Hello, i try to create new component with a TShape fields attached. It inherits from TMemo and in fact it is a simple memo with shape located under, working as a colour indicator (you write some text and colour is changing, nevermind ). I have some start (with static shape placement on component create) but after component installation when i put my component on the form the tshape element is not visible. What can I do to make it be visible below my memo? This is what i have now: Code: [Select]unit DMemo; {$mode objfpc}{$H+} interface uses   Classes, SysUtils, LResources, Forms, Controls, Graphics, Dialogs, StdCtrls, ExtCtrls; type   { TDMemo }   TDMemo = class(TMemo)   private     FShape: TShape;   protected     { Protected declarations }   public     constructor Create(AOwner: TComponent); override;   published   end; procedure Register; implementation procedure Register; begin   RegisterComponents('Experimental',[TDMemo]); end; { TDMemo } constructor TDMemo.Create(AOwner: TComponent); begin   inherited Create(AOwner);   if FShape <> nil then Exit;   FShape := TShape.Create(self);   FShape.Visible:= Visible;   FShape.Parent := Parent;   FShape.Top:=10;   FShape.Width:=100;   FShape.Left:=10;   FShape.Height:=20;   FShape.Shape:= stRectangle;   FShape.Pen.Style:= psSolid;   FShape.Pen.Color:= clRed; end; end. I work with Lazarus 1.2.4 and FPC 2.6.4 on Ubuntu 14.04. Best! ---------------------------------------------------------------------- Bart · 2014-08-12 19:44 Override SetParent of your component to set the parent of the FShape as well? Untested proposition b.t.w. Code: [Select]procedure TDMemo.SetParent(NewParent: TWinControl); begin   Inherited SetParent(NewParent);   FShape.Parent := NewParent; end; Bart ---------------------------------------------------------------------- vix · 2014-08-12 20:05 You are the man! Didn't know about that. Now it works as expected, thank You very much Best!