Call onpaint method lazarus / 8-Other ---------------------------------------------------------------------- IndianaJones · 2009-05-22 10:48 Hi all, How can i call any component's onpaint evet from procedure or function, or not just onpaint any event? Thanks ---------------------------------------------------------------------- theo · 2009-05-22 11:04 Invalidate, Repaint or Refresh. ---------------------------------------------------------------------- IndianaJones · 2009-05-22 11:16 Is there any other method instead of these? Thanks for the information. ---------------------------------------------------------------------- theo · 2009-05-22 13:02 Quote from: IndianaJones on May 22, 2009, 01:16:54 pmIs there any other method instead of these? Aren't these enough? ---------------------------------------------------------------------- IndianaJones · 2009-05-22 16:42 No, these are enough. Bu I just want to know is there any tricky way? ---------------------------------------------------------------------- Vincent Snijders · 2009-05-22 17:02 Maybe you can use the win32 widgetset, it is more forgiving for painting outside the paint event. ---------------------------------------------------------------------- IndianaJones · 2009-05-22 17:40 I have tested the following source code, here in this code the onpaint event fired from the Form, but in here the paint event doesnt work whenever drag the form the paint event triggered. So I read an article written like this: "This is the order of the initialization. OnCreate -> OnShow -> OnActivate -> OnPaint -> OnResize -> OnPaint ... and so on. OnPaint, OnResize Events like OnPaint and OnResize are always called after the form is initially created, but are also called repeatedly. OnPaint occurs before any controls on the form are painted (use it for special painting on the form)." Here is the question then if "use it for special painting on the form" is written why does the following code doesnt work properly. Thanks procedure TForm1.FormPaint(Sender: TObject); var   r:TRect; begin   r.TopLeft:=bevel1.ReadBounds.TopLeft;   r.BottomRight:=bevel1.ReadBounds.BottomRight;   Bevel1.Canvas.Pen.Color:=clRed;   Bevel1.Canvas.Brush.Color:=clRed;   Bevel1.Canvas.Rectangle(r);   Bevel1.Canvas.FillRect(r); end; ---------------------------------------------------------------------- Vincent Snijders · 2009-05-22 17:47 I still don't understand where the problem is. If I understood the textbook correctly, then this FormPaint code should rather be Bevel1's OnPaint code. ---------------------------------------------------------------------- IndianaJones · 2009-05-22 17:58 Yes mostly, but rather than Bevel's OnPaint event whenever the mentioned code put into the Form's OnPaint method this must be painted as well because of the written text or quote. PS. Follow the bold red text. "This is the order of the initialization. OnCreate -> OnShow -> OnActivate -> OnPaint -> OnResize -> OnPaint ... and so on. OnPaint, OnResize Events like OnPaint and OnResize are always called after the form is initially created, but are also called repeatedly. OnPaint occurs before any controls on the form are painted (use it for special painting on the form)." ---------------------------------------------------------------------- Vincent Snijders · 2009-05-22 18:12 That seems to be from a Delphi article and might not apply to the LCL. Anyway, in the OnPaint event of a form, you may only paint on the Canvas of the form. ---------------------------------------------------------------------- IndianaJones · 2009-05-22 18:15 Yep you are right, it is a Delphi article. here is the link http://delphi.about.com/od/formsdialogs/a/delphiformlife.htm So will apply in the near future or not apply, never. Thanks for the dialog. ---------------------------------------------------------------------- Vincent Snijders · 2009-05-22 18:22 I think it applies: OnPaint occurs before any controls on the form are painted (use it for special painting on the Form). So, on the Form, and not on Bevel1.