Animate.cpp
上传用户:lulishicai
上传日期:2010-03-01
资源大小:13202k
文件大小:4k
源码类别:

Delphi/CppBuilder

开发平台:

C++ Builder

  1. //---------------------------------------------------------------------------
  2. #include <vcl.h>
  3. #pragma hdrstop
  4. #include "Animate.h"
  5. //---------------------------------------------------------------------------
  6. #pragma package(smart_init)
  7. #pragma resource "*.dfm"
  8. TForm1 *Form1;
  9. //---------------------------------------------------------------------------
  10. __fastcall TForm1::TForm1(TComponent* Owner)
  11.         : TForm(Owner)
  12. {
  13. }
  14. //---------------------------------------------------------------------------
  15. void __fastcall TForm1::FormCreate(TObject *Sender)
  16. {
  17. Form1->ListBox1->Items->Add("aviNone");
  18. Form1->ListBox1->Items->Add("aviFindFolder");
  19. Form1->ListBox1->Items->Add("aviFindFile");
  20. Form1->ListBox1->Items->Add("aviFindComputer");
  21. Form1->ListBox1->Items->Add("aviCopyFiles");
  22. Form1->ListBox1->Items->Add("aviCopyFile");
  23. Form1->ListBox1->Items->Add("aviRecycleFile");
  24. Form1->ListBox1->Items->Add("aviEmptyRecycle");
  25. Form1->ListBox1->Items->Add("aviDeleteFile");
  26. //为列表框添加列表项
  27. Form1->Animate1->AutoSize=true;
  28. //控件会自动适应动画的尺寸
  29. Form1->Animate1->Transparent=true;
  30. //不显示背景色
  31. Form1->Edit1->Text=IntToStr(Form1->Animate1->FrameCount);
  32. Form1->Edit2->Text="高"+IntToStr(Form1->Animate1->FrameHeight)+"宽"+IntToStr(Form1->Animate1->FrameWidth);
  33. Form1->Edit3->Text=IntToStr(Form1->Animate1->StartFrame);
  34. Form1->Edit4->Text=IntToStr(Form1->Animate1->StopFrame);
  35. Form1->Edit5->Text='0';
  36. //初始化文本框状态
  37. }
  38. //---------------------------------------------------------------------------
  39. void __fastcall TForm1::Timer1Timer(TObject *Sender)
  40. {
  41. Form1->Animate1->Transparent=!Form1->CheckBox1->Checked;
  42. //设置背景色是否可见
  43. Form1->Edit1->Text=IntToStr(Form1->Animate1->FrameCount);
  44. Form1->Edit2->Text="高"+IntToStr(Form1->Animate1->FrameHeight)+"宽"+IntToStr(Form1->Animate1->FrameWidth);
  45. Form1->Edit3->Text=IntToStr(Form1->Animate1->StartFrame);
  46. Form1->Edit4->Text=IntToStr(Form1->Animate1->StopFrame);
  47. //设置文本框中的显示文本
  48. }
  49. //---------------------------------------------------------------------------
  50. void __fastcall TForm1::CheckBox1Click(TObject *Sender)
  51. {
  52. if (Form1->CheckBox1->Checked)
  53.    {
  54.    Form1->Animate1->Transparent=!Form1->Animate1->Transparent;
  55.    Form1->Animate1->Update();
  56.    }
  57.    //设置背景色是否可见
  58. }
  59. //---------------------------------------------------------------------------
  60. void __fastcall TForm1::ListBox1Click(TObject *Sender)
  61. {
  62. int i;
  63. int j;
  64. //定义变量
  65. for (i=0;i<=(ListBox1->Items->Count-1);i++)
  66.     {
  67.     if (ListBox1->Selected[i])
  68.        {
  69.         j=i;
  70.        }
  71.      }
  72. switch (j)
  73.        {
  74.        case 0:Form1->Animate1->CommonAVI=aviNone;
  75.               break;
  76.        case 1:Form1->Animate1->CommonAVI=aviFindFolder;
  77.               break;
  78.        case 2:Form1->Animate1->CommonAVI=aviFindFile;
  79.               break;
  80.        case 3:Form1->Animate1->CommonAVI=aviFindComputer;
  81.               break;
  82.        case 4:Form1->Animate1->CommonAVI=aviCopyFiles;
  83.               break;
  84.        case 5:Form1->Animate1->CommonAVI=aviCopyFile;
  85.               break;
  86.        case 6:Form1->Animate1->CommonAVI=aviRecycleFile;
  87.               break;
  88.        case 7:Form1->Animate1->CommonAVI=aviEmptyRecycle;
  89.               break;
  90.        case 8:Form1->Animate1->CommonAVI=aviDeleteFile;
  91.        }
  92.        //显示选中的动画
  93. }
  94. //---------------------------------------------------------------------------
  95. void __fastcall TForm1::Edit3Change(TObject *Sender)
  96. {
  97. Form1->Animate1->StartFrame=StrToInt(Form1->Edit3->Text);
  98. //设置动画开始的帧数
  99. }
  100. //---------------------------------------------------------------------------
  101. void __fastcall TForm1::Edit4Change(TObject *Sender)
  102. {
  103. Form1->Animate1->StopFrame=StrToInt(Form1->Edit4->Text);
  104. //设置动画结束的帧数
  105. }
  106. //---------------------------------------------------------------------------
  107. void __fastcall TForm1::Edit5Change(TObject *Sender)
  108. {
  109. Form1->Animate1->Seek(StrToInt(Form1->Edit5->Text));
  110. //跳到指定的帧数
  111. }
  112. //---------------------------------------------------------------------------
  113. void __fastcall TForm1::ListBox1DblClick(TObject *Sender)
  114. {
  115. Form1->Animate1->Active=!Form1->Animate1->Active;
  116. //开始或停止动画
  117. }
  118. //---------------------------------------------------------------------------
  119.