First, download the Tgifimage.pas unit first. Step: [Project]-->[add to Project ...] Select the Tgifimage.pas unit and compile it.
When using Timage to load the display GIF is usually installed tgifimage to extend the implementation, there will be dynamic creation of controls in use, but if the GIF picture is loaded directly, GIF animation will not move, it is necessary to create a Tgifimage class to load the animation, Finally, give it to timage. The code is as follows:
- Procedure Tform1.button1click (Sender:tobject);
- Var
- Objimg:timage;
- Objgif:tgifimage;
- Begin
- If Opendialog1.execute Then
- Begin
- Objimg: = Timage.create (self);
- Objimg.parent: = self;
- Objimg.setbounds (10, 20, 140, 200);
- Objgif: = tgifimage.create;
- Objgif.loadfromfile (Opendialog1.filename);
- ObjImg.Picture.Assign (objgif);
- Tgifimage (objImg.Picture.Graphic). Animate: = True;
- End
- End
Delphi Loading GIF images