Example of Adding Silent Video Clips
Go Up to Adding Silent Video Clips to an Application
Suppose you want to display an animated logo as the first screen that appears when your application starts. After the logo finishes playing the screen disappears.
To run this example, create a new project and save the Unit1.pas file as Frmlogo.pas and save the Project1.dpr file as Logo.dpr. Then:
- Double-click the animate icon from the Win32 category of the Tool palette.
- Using the Object Inspector, set its Name property to Logo1.
- Select its FileName property, click the ellipsis (...) button, locate and choose an AVI file. Then click Open in the Open AVI dialog.This loads the AVI file into memory.
- Position the animation control box on the form by clicking and dragging it to the top right hand side of the form.
- Set its Repetitions property to 5.
- Click the form to bring focus to it and set its Name property to LogoForm1 and its Caption property to Logo Window. Now decrease the height of the form to right-center the animation control on it.
- Double-click the value field of the OnActivate event and write the following code to run the AVI clip when the form is in focus at run-time:
Logo1.Active := True;
Logo1->Active = true;
- Double-click the Label icon on the Standard category of the Tool palette. Select its Caption property and enter Welcome to Cool Images 4.0. Now select its Font property, click the ellipsis (...) button and choose Font Style: Bold, Size: 18, Color: Navy from the Font dialog and click OK. Click and drag the label control to center it on the form.
- Click the animation control to bring focus back to it. Double-click its OnStop event and write the following code to close the form when the AVI file stops:
LogoForm1.Close;
LogoForm1->Close();
- Select Run > Run to execute the animated logo window.
Note: If you are using either Windows Vista or Windows 7, you need to add ShellAnimations to your
uses
clause (Delphi) or#include
ShellAnimations (C++) so that the CommonAVIs (such as Vcl.ComCtrls.TAnimateParams.CommonAVI) work correctly. This addition links AVI resources similar to the ones in Windows XP.