Unvisual TPaintBox creation lazarus / 7-LCL ---------------------------------------------------------------------- bakacirno · 2012-05-18 03:13 Hello, im trying to create working TPaintBox without lazarus help, i.e. in plain text, but it doesnt work for me no matter what i try Im trying it like that: Code: [Select]unit main; {$mode objfpc}{$H+} interface uses  Classes, SysUtils, Forms, Controls, Dialogs, ExtCtrls, Menus, Graphics; type  TForm1 = class(TForm)   PaintBox1: TPaintBox;   procedure FormCreate(Sender: TObject);  end; var  Form1: TForm1; implementation procedure TForm1.FormCreate(Sender: TObject); begin  PaintBox1 := TPaintBox.Create(Self);  PaintBox1.Parent := Form1;  PaintBox1.Visible := true;  PaintBox1.Align := alClient;  PaintBox1.Canvas.Pen.color := clBlack;  PaintBox1.Canvas.FillRect(20,20,40,40); end; end. It gives me an empty form without black rectangle which is supposed to be here, what i am doing wrong? I googled hard, but no luck. ---------------------------------------------------------------------- Leledumbo · 2012-05-18 06:20 Create an OnPaint event for PaintBox1, assign it to PaintBox1.OnPaint, and move the FillRect there. ---------------------------------------------------------------------- bakacirno · 2012-05-18 06:52 Many thanks for you reply, now it works. I was looking for some sort of OnCreate method for PaintBox, but found none. I was thinking OnPaint is for events related for actually painting on canvas. Also sorry, i didnt meant to create topic in Suggensions forum section, it was an accident.