Author: Lou Adler
Adding an AVI in your EXE File
Answer:
In Notepad type or some other simple text editor type:
MyAvi AVI "some.avi"
or
100 AVI "some.avi"
depending on how you want to reference the identifier. You will want to know
whether it is referenced by a resource name or a resource ID when you write the
code to play the AVI.
Save the file with a .RC extension
You will be using the Animate Component to play the file, therefore the same rules
apply, like no sound can be with the AVI.
Use Borland's Resource Compiler: BRCC32.EXE to convert the file to a .RES file. At
the dos prompt type the following:
brcc32 myfile.rc
This is some code to play an animation using the Resource Name:
A
1 nimate.ResHandle := 0;
2 Animate.ResName := 'MyAvi';
3 Animate.Active := True;
To stop an animation, call the Stop method.
Place the following code to add your resource file into your executable.
{$R MYFILE.RES}
A sample file is listed below of how this would work correctly:
4 unit AviResU;
5 6 interface7 8 uses9 Forms, ComCtrls, StdCtrls, Classes, Controls;
10 11 type12 TForm1 = class(TForm)
13 PlayBtn: TButton;
14 Animate: TAnimate;
15 StopBtn: TButton;
16 procedure PlayBtnClick(Sender: TObject);
17 procedure StopBtnClick(Sender: TObject);
18 private19 { Private declarations }20 public21 { Public declarations }22 end;
23 24 var25 Form1: TForm1;
26 27 implementation28 29 {$R *.DFM}30 {$R AVIRESRC.RES}31 32 procedure TForm1.PlayBtnClick(Sender: TObject);
33 begin34 Animate.ResHandle := 0;
35 Animate.ResName := 'TurboGuy';
36 Animate.Active := True;
37 PlayBtn.Enabled := False;
38 StopBtn.Enabled := True;
39 end;
40 41 procedure TForm1.StopBtnClick(Sender: TObject);
42 begin43 Animate.Stop;
44 PlayBtn.Enabled := True;
45 StopBtn.Enabled := False;
46 end;
47 48 end.