where : ibrtses delphi

flickering images

disclaimer

the source code of this page may not appear correctly in certain browsers
due to special characters. Have a look at the source of this HTML page
with notepad instead


The point here is to suppress the flickering. Fast reloading images tend
to flicker, as Windows erases the background before painting the image.
This happens when images are reloaded in a loop into a TImage, or when
updating scenes in OpenGL. There are several possibilities :

handle the EraseBackground message

The TWinControl message handler is overridden.
insert a procedure into the form :
 type 
  TForm1=class(TForm)
   ..
   procedure WMEraseBkgnd(var message:TWMEraseBkgnd); message  WM_ERASEBKGND;
  private
   ..
  public
   ..
 end;

 
procedure TForm1.WMEraseBkgnd(var message:TWMEraseBkgnd);
begin
 message.result:=1;
end;
this means all background erase of this form are cancelled.

Change the controlstyle of the form

Change the ControlStyle in the formpaint.
procedure TForm1.FormPaint(Sender:TObject);
begin
 ControlStyle:=ControlStyle+ [csOpaque];
 .. 
end;

Use doublebuffering

This does not help with OpenGL, as the rendering context is different.
But it was recommended when the refresh method flickers on some components.
Form1.Doublebuffered:=true;



Feedback is welcome





sponsored links




Delphi
home

last updated: 4.june.99

Copyright (99,2000) Ing.Büro R.Tschaggelar