Getting rid of the flickering

I am using a descendent of TSpeedButton which adds gradient. I added a OnMouseEnter and OnMouseLeave to it so that the bevel appears when the mouse enters and disapears when it leaves. When moving the mouse around fast enough, this creates some flickering. How can I get rid of that ?

{Create the button}
constructor TGradBtn.Create(AOwner: TComponent);
begin
{Get all methods of ancestor (TSpeedButton) }
inherited Create(AOwner);
ControlStyle := ControlStyle + [csOpaque];
{Set the default properties. This is the way the button appears }
{when you first place it on a form or create it at runtime. You can }
{change these if you don't like the default properties! }
Width:=100;
Height:=30;
fGradColor:= clBlue;
fFaceColor:= clBlack;
fHighlightColor:= clWhite;
fBottomColor:= clBlack;
fBevWidth:= 1;
fRectWidth:= 1;
{Create the background bitmap. It is freed in the "destroy" procedure}
BackGround:=TBitmap.Create;
BackGround.Width:=Width;
BackGround.Height:=Height;
{Draw the gradient colors to the background bitmap for future painting}
GradFill(fGradColor, fFaceColor, BackGround);
Font.Color:=clWhite;
Caption:='TGradBtn';
end;

oh, well, I'm sure there is a way to do that... It's just that I don't know of it,,,, If you get any suggestions to fix this please let me know..thanx

Regards,
Viktor Ivanov

0

moonriseAuthor Commented: 1998-08-07

Thank you John. It works great.

0

bobspencerrCommented: 2002-04-14

Have you thought of using the invalidaterect function as this limits the refresh paint of the form tyo the area specified in the function. I have writtena component which flickered like mad until I set (owner as tform).doublebuffered:=true; and used the invalidaterect facility. Flicker reduced to nil