[Lazarus] Form events firing order and count

Ondrej Pokorny lazarus at kluug.net
Sun Feb 18 19:42:11 CET 2018


On 18.02.2018 17:19, Giuliano Colla wrote:
> Il 18/02/2018 11:54, Ondrej Pokorny ha scritto:
>
>> What events are generated?
>
> onFormPaint

Do you mean TForm.OnPaint?

---

No, no, no, no. Setting MyLabel.Color and any other visual property does 
NOT fire any paint event/method/whatever - neither in Delphi nor in 
Lazarus. Instead a repaint is requested with Invalidate/InvalidateRect 
that is then handled when the WM_PAINT message is received.

I really don't know where you got this information from. Or did I 
misunderstand you?

Ondrej

---

PS: A test project:

unit Unit1;

interface

uses
   Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, 
System.Classes, Vcl.Graphics,
   Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls;

type
   TForm1 = class(TForm)
     Label1: TLabel;
     Button1: TButton;
     procedure Button1Click(Sender: TObject);
     procedure FormPaint(Sender: TObject);
   private
     { Private declarations }
   public
     { Public declarations }
   end;

var
   Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
begin
   Writeln('1');
   Label1.Color := clRed;
   Writeln('2');
   Label1.Color := clGreen;
   Writeln('3');
end;

procedure TForm1.FormPaint(Sender: TObject);
begin
   Caption := IntToStr(StrToIntDef(Caption, 0)+1);
   Writeln('paint');
end;

end.



object Form1: TForm1
   Left = 0
   Top = 0
   Caption = 'Form1'
   ClientHeight = 561
   ClientWidth = 391
   Color = clBtnFace
   Font.Charset = DEFAULT_CHARSET
   Font.Color = clWindowText
   Font.Height = -11
   Font.Name = 'Tahoma'
   Font.Style = []
   OldCreateOrder = False
   OnPaint = FormPaint
   PixelsPerInch = 96
   TextHeight = 13
   object Label1: TLabel
     Left = 80
     Top = 112
     Width = 31
     Height = 13
     Caption = 'Label1'
   end
   object Button1: TButton
     Left = 80
     Top = 155
     Width = 75
     Height = 25
     Caption = 'Button1'
     TabOrder = 0
     OnClick = Button1Click
   end
end


More information about the Lazarus mailing list