2010. június 6., vasárnap
Adding an AVI in your EXE File
Problem/Question/Abstract:
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:
Animate.ResHandle := 0;
Animate.ResName := 'MyAvi';
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:
unit AviResU;
interface
uses
Forms, ComCtrls, StdCtrls, Classes, Controls;
type
TForm1 = class(TForm)
PlayBtn: TButton;
Animate: TAnimate;
StopBtn: TButton;
procedure PlayBtnClick(Sender: TObject);
procedure StopBtnClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
{$R AVIRESRC.RES}
procedure TForm1.PlayBtnClick(Sender: TObject);
begin
Animate.ResHandle := 0;
Animate.ResName := 'TurboGuy';
Animate.Active := True;
PlayBtn.Enabled := False;
StopBtn.Enabled := True;
end;
procedure TForm1.StopBtnClick(Sender: TObject);
begin
Animate.Stop;
PlayBtn.Enabled := True;
StopBtn.Enabled := False;
end;
end.
Feliratkozás:
Megjegyzések küldése (Atom)
Nincsenek megjegyzések:
Megjegyzés küldése