[lazarus] Just for fun...

andrew johnson acjgenius at earthlink.net
Mon Nov 4 10:32:10 EST 2002

I took a look see, and first off you forgot the lfm/lrs.. a good thing
its such a simple example. ;) In something like this you should always
package up the pp, lfm, & lrs, and its best if you tar/zip them up so
you don't fill up everybody's mailbox!

But as for the flickering. The problem is that TWinControl Double
Buffering does not yet work, this means child controls may often flash
in a situation such as this one(for instance TImage will have very
noticeable flashing with some images). Given what you are trying, it may
make sense to compare what it _should_ like with what it actually _does_
by implementing a buffer routine in its own Paint routine. I tried it
and it looked much better. This what I replaced the paint routine with :

procedure TMotoMetr.Paint;
  TempBit : Longint;
  DrawHandle := Canvas.Handle;
  TempHandle := CreateCompatibleDC(0);
  TempBit := CreateCompatibleBitmap(TempHandle, Width + 1, Height + 1);
  SelectObject(TempHandle, TempBit);
  Canvas.Handle := TempHandle;
  with Canvas do
    PaintBackground(Canvas);  {Hintergrundbitmap erstellen}
    PaintNeedle(Canvas);   {Zeiger des MotoMeters wird über das Bitmap
  BitBlt(DrawHandle, 0, 0, Width + 1, Height + 1, TempHandle, 0, 0,
  Canvas.Handle := DrawHandle;

This requires LCLLinux to be added to the uses. 

Also you should note that refresh will not invalidate the component(it
does a bunch of nothing). To truly refresh you must call to invalidate


On Mon, 2002-11-04 at 07:35, David Creelman wrote:
> Hi All,
> As a kind of fun measure of how far along Lazarus is, I went to the
> Delphi Superpage and downloaded a TGraphicControl descended component
> just to see how easy it was to pull it into Lazarus.
> I chose TMotoMeter, originally written for Delphi 1.0 by (B.
> Drehzahlmesser ), which displays a simple speedometer with some danger
> bands on it. There was a winprocs.Polygon call that needed to be
> translated to a call to Polygon and a SetTextAlign command that needed
> to be commented out (don't know it's equivalent in lcl land) and it
> worked fine !
> Here is a pic of it working and a copy of the source if you are
> interested in toying around with it. 
> To get the speed marker to clear itself on a change, you'll need to
> issue a refresh and it does flash a fair bit. I expect that will get
> fixed later on.... Andreas, why does it flash like that ? Which part of
> Graphics.pas needs to change here ?
> Cheers
> DC

More information about the Lazarus mailing list