[SOLVED] Manually adding user generated Controls lazarus / 31-LCL ---------------------------------------------------------------------- Nitorami · 2017-10-01 16:23 I am trying to add a paintbox to Form1 per Menu Click but it does not work. Nothing shows up, and I am feeling really stupid here. 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 procedure TForm1.MenuItem1Click(Sender: TObject);begin   try     TestBox := TPaintbox.Create(Self);     TestBox.Parent:=self;     Label1.Caption := 'TestBox generated...'     with TestBox do begin       Left := 10; Top  := 10;  Width := 50; Height := 50;       Canvas.Brush.Style := bsSolid;       Canvas.Brush.Color := clblue;       Canvas.Rectangle(5,5,8,8);       Canvas.FillRect(0,0,10,10);     end;   finally   end;end; ---------------------------------------------------------------------- bytebites · 2017-10-01 16:34 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 procedure TForm1.Button1Click(Sender: TObject);begin     try     TestBox := TPaintbox.Create(Self);     TestBox.Parent:=self;     Label1.Caption := 'TestBox generated...';     with TestBox do begin       Left := 10; Top  := 10;  Width := 50; Height := 50;       OnPaint:=PaintBox1paint;     end;   finally   end;end; procedure TForm1.PaintBox1Paint(Sender: TObject);begin   Canvas.Brush.Style := bsSolid;   Canvas.Brush.Color := clblue;   Canvas.Rectangle(5,5,8,8);   Canvas.FillRect(0,0,10,10);end; ---------------------------------------------------------------------- Nitorami · 2017-10-01 16:46 Ah, I see, I need to specify an OnPaint Event. Thank you. Edit: Wait. The PaintBox1Paint executes, but I still cannot see anything. Aha, it should say 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 procedure TForm1.PaintBox1Paint(Sender: TObject);begin  with TPaintBox(Sender) do begin   Canvas.Brush.Style := bsSolid;   Canvas.Brush.Color := clblue;   Canvas.Rectangle(5,5,8,8);   Canvas.FillRect(0,0,10,10);end;end;