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

Delphi/CppBuilder

开发平台:

C++ Builder

  1. //---------------------------------------------------------------------------
  2. #include <vcl.h>
  3. #pragma hdrstop
  4. #include "GUnit.h"
  5. //---------------------------------------------------------------------------
  6. #pragma package(smart_init)
  7. #pragma link "AniGIFCtrl_OCX"
  8. #pragma resource "*.dfm"
  9. TForm1 *Form1;
  10. //---------------------------------------------------------------------------
  11. __fastcall TForm1::TForm1(TComponent* Owner)
  12.         : TForm(Owner)
  13. {
  14. }
  15. //---------------------------------------------------------------------------
  16. void __fastcall TForm1::Button1Click(TObject *Sender)
  17. {
  18.     WideString sFile;
  19.     OpenDialog1->Title="请选择一个GIF动画文件:";
  20.     OpenDialog1->Filter ="GIF动画文件(*.gif)|*.gif";
  21.     //设置OpenDialog控件的标志和属性
  22.     OpenDialog1->Execute();
  23.     if(OpenDialog1->FileName!="")
  24.     {
  25.        sFile=OpenDialog1->FileName;
  26.        AniGIF1->ReadGIF(sFile);
  27.        AniGIF1->Stop();
  28.        AniGIF1->AutoRewind=true;
  29.        //打开文件
  30.     }
  31.     Edit1->Text=IntToStr(AniGIF1->GIFHeight);
  32.     Edit2->Text=IntToStr(AniGIF1->GIFWidth);
  33.     Edit3->Text=IntToStr(AniGIF1->Frames);
  34.     Edit4->Text=IntToStr(AniGIF1->Frame);
  35.     //显示文件信息
  36.     ScrollBar1->Max=AniGIF1->Frames;
  37.     ScrollBar1->Min=0;
  38.     //设置滚动条参数
  39.     Edit5->Text=sFile;
  40.     //显示文件路径和文件名
  41.     Button2->Enabled=true;
  42.     //设置按钮有效状态
  43. }
  44. //---------------------------------------------------------------------------
  45. void __fastcall TForm1::Button2Click(TObject *Sender)
  46. {
  47.     AniGIF1->Play();
  48.     //播放文件
  49.     Button3->Enabled=true;
  50.     //设置按钮有效状态
  51.         
  52. }
  53. //---------------------------------------------------------------------------
  54. void __fastcall TForm1::Button3Click(TObject *Sender)
  55. {
  56.     AniGIF1->Stop();
  57.     //停止播放
  58.     Button3->Enabled=false;
  59.     //设置按钮有效状态
  60.         
  61. }
  62. //---------------------------------------------------------------------------
  63. void __fastcall TForm1::AniGIF1Step(TObject *Sender)
  64. {
  65.     ScrollBar1->Position=AniGIF1->Frame;
  66.     //设置滚动条上滑块位置
  67.     Edit4->Text=IntToStr(AniGIF1->Frame);
  68.     //显示当前播放位置
  69.     ScrollBar2->Position=AniGIF1->Speed;
  70.     //显示播放速度
  71.         
  72. }
  73. //---------------------------------------------------------------------------
  74. void __fastcall TForm1::ScrollBar2Scroll(TObject *Sender,
  75.       TScrollCode ScrollCode, int &ScrollPos)
  76. {
  77.     AniGIF1->Speed=ScrollBar2->Position;
  78.     //设置播放速度
  79.         
  80. }
  81. //---------------------------------------------------------------------------
  82. void __fastcall TForm1::ScrollBar1Scroll(TObject *Sender,
  83.       TScrollCode ScrollCode, int &ScrollPos)
  84. {
  85.     AniGIF1->Frame=ScrollBar1->Position;
  86.     //设置播放位置
  87.     Edit4->Text=IntToStr(AniGIF1->Frame);
  88.     //显示播放位置
  89.         
  90. }
  91. //---------------------------------------------------------------------------
  92. void __fastcall TForm1::FormCreate(TObject *Sender)
  93. {
  94.     ScrollBar2->Min=1;
  95.     ScrollBar2->Max=6;
  96.     //设置滚动条参数
  97.     Edit1->Text=IntToStr(AniGIF1->GIFHeight);
  98.     Edit2->Text=IntToStr(AniGIF1->GIFWidth);
  99.     Edit3->Text=IntToStr(AniGIF1->Frames);
  100.     Edit4->Text=IntToStr(AniGIF1->Frame);
  101.     //设置文本显示
  102.     ScrollBar1->Max=AniGIF1->Frames;
  103.     ScrollBar1->Min=0;
  104.     //设置滚动条参数
  105.     Edit5->Text=OpenDialog1->FileName;
  106.     Button2->Enabled=false;
  107.     Button3->Enabled=false;
  108.     //设置按钮有效状态
  109.         
  110. }
  111. //---------------------------------------------------------------------------