On Thursday 15 June 2006 8:54 pm, Patrick Chevalley wrote: > In a first time I set the background of the underlaying panel to black > but this is not necessary and now it is clBtnface. > The sky chart is first draw to a Tbitmap. In the drawing component > onPaint I just draw this bitmap to the canvas along with temporary > drawing if any (selection mark, ...). > Using a Timage there is a lot of flicker, when resizing, but also when > drawing a temporary lines directly with pen.mode=pmXor. > With the drawing component there is no problem.
You are right and it works on Linux even without the DoubleBuffered := True! The presence of the control must stop (or clip) the GTK1 form background fill. > > This is unfortunately not the most simple application to use as an > example but if you want to look at the source code it is at: > http://svn.sourceforge.net/viewcvs.cgi/skychart/trunk/skychart/ > The drawing component is in pu_chart.pas. > > Patrick > I tried to simplify the code to make it easier to see how the form and the control relate. In so doing I realised you could make direct use of TCustomControl if all you want to do is take over the client area painting: unit Main; {$mode objfpc}{$H+} interface uses Classes, SysUtils, LResources, Forms, Controls, Graphics, Dialogs; type TMainForm = class(TForm) procedure FormCreate(Sender: TObject); procedure FormDestroy(Sender: TObject); private { private declarations } PainterControl: TCustomControl; public { public declarations } Procedure ControlPaint(Sender: TObject); end; var MainForm: TMainForm; implementation procedure TMainForm.FormCreate(Sender: TObject); begin PainterControl := TCustomControl.Create(Self); PainterControl.Align := alClient; PainterControl.OnPaint := @ControlPaint; PainterControl.Parent := Self; PainterControl.DoubleBuffered := True; end; procedure TMainForm.FormDestroy(Sender: TObject); begin PainterControl.Free; end; Procedure TMainForm.ControlPaint(Sender: TObject); Begin with PainterControl.Canvas do begin Brush.Color:=clRed; FillRect(ClientRect); end; End; initialization {$I Main.lrs} end. Of course you would want to create a descendent control if you want to do anything else, such as the mouse handling in SkyChart! Thanks again for you help, I hope the above is useful to others. Paul > _________________________________________________________________ > To unsubscribe: mail [EMAIL PROTECTED] with > "unsubscribe" as the Subject > archives at http://www.lazarus.freepascal.org/mailarchives _________________________________________________________________ To unsubscribe: mail [EMAIL PROTECTED] with "unsubscribe" as the Subject archives at http://www.lazarus.freepascal.org/mailarchives
