ronaldosantana
ronaldosantana

Reputation: 5252

Animated GIF and TDrawgrid in Delphi 2007

I am being able to draw the image using something like the code below:

ACanvas.Draw(ARect.Left+16, ARect.Top+4, imgGIF.Picture.Graphic )

Now the gif for that imgGIF component is being loaded via

  GIF := TGifImage.Create;
  GIF.LoadFromFile('path\to\gif\processing.gif');
  GIF.Animate := True;
  imgGIF.Picture.Graphic.Assign(GIF);

I am setting

GIFImageDefaultAnimate := True;
GIFImageDefaultTransparent := True;

The environment is Delphi 2007, using the TGifImage that comes with the Delphi 2007 DVD. Is this even possible? To display an animated GIF on a TDrawgrid Cell?

I don't think it is since canvas.draw is only drawing the image, not inserting the component into the cell - so as far as I can understand, it is only drawing the firm image on the gif.

Upvotes: 3

Views: 1578

Answers (1)

Remy Lebeau
Remy Lebeau

Reputation: 598299

When TGIFImage.Animate is set to True, calling Canvas.Draw() will render the current frame of the animation. When the TGIFImage is placed inside a TImage, TImage uses the TGraphic.OnChange event to automatically redraw the latest frame as the animation is running. To do the same thing with the TDrawGrid, you will have to call Canvas.Draw() periodically, such as in a timer whose interval is set to the value of the TGIFImage.FrameDelay property. Otherwise, load the GIF image into a separate TGIFImage instance for the TDrawGrid's use so you can utilize the TGraphic.OnChange event.

Upvotes: 3

Related Questions