canvas painting disappear after a form drop on lazarus / 39-Graphics ---------------------------------------------------------------------- ali-libre · 2017-03-01 12:10 painting disappear after a new form drop on my form I don't use window manager and reapaint are exoensive to me. What can i do? ---------------------------------------------------------------------- howardpc · 2017-03-01 12:56 Use the form's OnPaint event to do the drawing? ---------------------------------------------------------------------- circular · 2017-03-01 19:51 Otherwise draw in a bitmap and in the OnPaint event just draw the bitmap ---------------------------------------------------------------------- ali-libre · 2017-03-02 11:06 i have a map to see if mouse rally leave form and then back repait But onmouseleave execute on move on each element on the form! Is ther any event show really mouse leave the form. ---------------------------------------------------------------------- RAW · 2017-03-02 12:20 I don't know if I understand what you want... Anyway.. you can create your own TIMER. WINDOWS example: 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.Timer1Timer(Sender: TObject); Begin  If Not PtInRect(Self.BoundsRect, Mouse.CursorPos)  Then Color:= clBlue  Else Color:= clWhite; End; EDIT: Funny if I use "bsNone" then this is working, but with "bsSizeable" it's not working. If the cursor is at the bottom of the form then the color turns into blue. ---------------------------------------------------------------------- howardpc · 2017-03-02 14:35 OnMouseLeave (and OnMouseEnter) does not seem to be implemented for TForm. However, that can be remedied without needing a timer. In a new blank Lazarus project set the OnCreate, OnMouseEnter and OnMouseLeave events of Form1 as follows (this deals only with the form client area - to get the full form bounds is more complicated): 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 unit Unit1; {$Mode objfpc}{$H+}{$AppType console} interface uses  SysUtils, Forms, Controls, LCLIntf, Classes; type   TForm1 = class(TForm)    procedure FormCreate(Sender: TObject);    procedure FormMouseEnter(Sender: TObject);    procedure FormMouseLeave(Sender: TObject);  private    FPriorMouseWithin: Boolean;    FMouseWithinClient: Boolean;    FInitialised: Boolean;    procedure DoMouseLeave;    procedure DoMouseEnter;    procedure Form1OnIdle(Sender: TObject; var Done: Boolean);  public   end; var  Form1: TForm1; implementation {$R *.lfm} procedure TForm1.FormCreate(Sender: TObject);begin  FPriorMouseWithin:=PtInRect(ClientRect, ScreenToClient(Mouse.CursorPos));  Application.OnIdle:=@Form1OnIdle;end; procedure TForm1.FormMouseEnter(Sender: TObject);begin  WriteLn('FormMouseEnter');end; procedure TForm1.FormMouseLeave(Sender: TObject);begin  WriteLn('FormMouseLeave');end; procedure TForm1.DoMouseLeave;begin  if Assigned(OnMouseLeave) then    OnMouseLeave(Self);end; procedure TForm1.DoMouseEnter;begin  if Assigned(OnMouseEnter) and FInitialised then    OnMouseEnter(Self);  if not FInitialised then    FInitialised:=True;end; procedure TForm1.Form1OnIdle(Sender: TObject; var Done: Boolean);begin  FMouseWithinClient:=PtInRect(ClientRect, ScreenToClient(Mouse.CursorPos));  if FPriorMouseWithin and not FMouseWithinClient then begin    FPriorMouseWithin:=False;    DoMouseLeave;  end  else if not FPriorMouseWithin and FMouseWithinClient then begin    FPriorMouseWithin:=True;    DoMouseEnter;  end;  Done:=True;end; end. ---------------------------------------------------------------------- RAW · 2017-03-02 16:07 Quote...does not seem to be implemented for TForm. On Windows 7 it's working fine (OnMouseLeave and OnMouseEnter), but if I move very fast then it fails. And yes only ClientArea is handled. EDIT: ClientRect is working fine in combination with "bsSizeable"... 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.Timer1Timer(Sender: TObject); Begin  If Not PtInRect(ClientRect, ScreenToClient(Mouse.CursorPos))  Then Color:= clBlue  Else Color:= clWhite; End;  Maybe it's just my CustomClassicTheme setting. ---------------------------------------------------------------------- howardpc · 2017-03-02 17:38 Quote from: RAW on March 02, 2017, 05:07:32 pmOn Windows 7 it's working fine (OnMouseLeave and OnMouseEnter), but if I move very fast then it fails. Since very rapid mouse movements will send message(s) before an OnIdle event occurs to interpret it/them using this rather naive code. ---------------------------------------------------------------------- ali-libre · 2017-03-02 19:19 sadly : both not worked. but i used on activated event and everything work fine...! but how a window manager make it unchangable ? whie program run in a window manager nothing been cleared but non-gui? can i activate such thing in my project or manually active this on simple x-org? ---------------------------------------------------------------------- ali-libre · 2017-03-02 22:07 can the element's pixel's be over write linke bake texture on 3D software? ---------------------------------------------------------------------- User137 · 2017-03-03 11:30 Quote from: ali-libre on March 01, 2017, 01:10:51 pmpainting disappear after a new form drop on my form I don't use window manager and reapaint are exoensive to me. What can i do?Have a TImage on form to hold all the canvas drawings. Draw on a image1.Picture.Bitmap.Canvas, but before that you need to ensure there is a canvas as large as the image, so 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 onFormCreate: image1.Align:=alClient; // stretch to form boundariesima ge1.Picture.Bitmap.Width:=ClientWidth;image1.Picture.Bitmap.Height:=Cl ientHeight;TImage's pixels never disappear when other form passes over, you don't need to repaint. ---------------------------------------------------------------------- ali-libre · 2017-03-03 21:38 good idea but what about performance? is it fast as simple component? ---------------------------------------------------------------------- howardpc · 2017-03-03 22:30 Speed of (re)drawing is not something you can reliably predict theoretically. If speed is of the essence, you would have to implement the two different solutions (each coded optimally), and time their performance on your system to see if there were any significant difference between them. In any case, a few milliseconds display differential is not noticeable to the human eye. It's not like we're talking OS boot-up time, or C++ project compilation time. ---------------------------------------------------------------------- ali-libre · 2017-03-11 22:20 no. i tested timage tonight an found timage not produced for fast painting i can fast draw on simple object but not timage i'm currently using tpaintbox. or timage have an option for fast drawing? or i must back to redraw? ---------------------------------------------------------------------- lainz · 2017-03-11 22:25 I agree better use TPaintBox. But as already said only repaint as needed not redraw the content too often. If you need speed at repaint better use OpenGL.