Imagem - animando e eliminando flicker |
Top Previous Next |
// Eliminando flicker
var FLockFormUpdatePile : integer;
procedure TForm1.LockFormUpdate; begin if FLockFormUpdatePile = 0 then Perform(WM_SetRedraw, 0, 0); inc(FLockFormUpdatePile); end;
procedure TForm1.UnlockFormUpdate; begin dec(FLockFormUpdatePile); if FLockFormUpdatePile = 0 then begin Perform(WM_SetRedraw, 1, 0); RedrawWindow(Handle, nil, 0, RDW_FRAME + RDW_INVALIDATE + RDW_ALLCHILDREN + RDW_NOINTERNALPAINT); end; end;
procedure TForm1.Timer1Timer(Sender: TObject); begin LockFormUpdate; Image1.Left := Image1.Left + 4; if Image1.Left > (ClientWidth - Image1.Width - 2) then Image1.Left := 2; UnLockFormUpdate; end; |