GUnit.cpp
上传用户:lulishicai
上传日期:2010-03-01
资源大小:13202k
文件大小:3k
源码类别:
Delphi/CppBuilder
开发平台:
C++ Builder
- //---------------------------------------------------------------------------
- #include <vcl.h>
- #pragma hdrstop
- #include "GUnit.h"
- //---------------------------------------------------------------------------
- #pragma package(smart_init)
- #pragma link "AniGIFCtrl_OCX"
- #pragma resource "*.dfm"
- TForm1 *Form1;
- //---------------------------------------------------------------------------
- __fastcall TForm1::TForm1(TComponent* Owner)
- : TForm(Owner)
- {
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::Button1Click(TObject *Sender)
- {
- WideString sFile;
- OpenDialog1->Title="请选择一个GIF动画文件:";
- OpenDialog1->Filter ="GIF动画文件(*.gif)|*.gif";
- //设置OpenDialog控件的标志和属性
- OpenDialog1->Execute();
- if(OpenDialog1->FileName!="")
- {
- sFile=OpenDialog1->FileName;
- AniGIF1->ReadGIF(sFile);
- AniGIF1->Stop();
- AniGIF1->AutoRewind=true;
- //打开文件
- }
- Edit1->Text=IntToStr(AniGIF1->GIFHeight);
- Edit2->Text=IntToStr(AniGIF1->GIFWidth);
- Edit3->Text=IntToStr(AniGIF1->Frames);
- Edit4->Text=IntToStr(AniGIF1->Frame);
- //显示文件信息
- ScrollBar1->Max=AniGIF1->Frames;
- ScrollBar1->Min=0;
- //设置滚动条参数
- Edit5->Text=sFile;
- //显示文件路径和文件名
- Button2->Enabled=true;
- //设置按钮有效状态
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::Button2Click(TObject *Sender)
- {
- AniGIF1->Play();
- //播放文件
- Button3->Enabled=true;
- //设置按钮有效状态
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::Button3Click(TObject *Sender)
- {
- AniGIF1->Stop();
- //停止播放
- Button3->Enabled=false;
- //设置按钮有效状态
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::AniGIF1Step(TObject *Sender)
- {
- ScrollBar1->Position=AniGIF1->Frame;
- //设置滚动条上滑块位置
- Edit4->Text=IntToStr(AniGIF1->Frame);
- //显示当前播放位置
- ScrollBar2->Position=AniGIF1->Speed;
- //显示播放速度
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::ScrollBar2Scroll(TObject *Sender,
- TScrollCode ScrollCode, int &ScrollPos)
- {
- AniGIF1->Speed=ScrollBar2->Position;
- //设置播放速度
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::ScrollBar1Scroll(TObject *Sender,
- TScrollCode ScrollCode, int &ScrollPos)
- {
- AniGIF1->Frame=ScrollBar1->Position;
- //设置播放位置
- Edit4->Text=IntToStr(AniGIF1->Frame);
- //显示播放位置
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::FormCreate(TObject *Sender)
- {
- ScrollBar2->Min=1;
- ScrollBar2->Max=6;
- //设置滚动条参数
- Edit1->Text=IntToStr(AniGIF1->GIFHeight);
- Edit2->Text=IntToStr(AniGIF1->GIFWidth);
- Edit3->Text=IntToStr(AniGIF1->Frames);
- Edit4->Text=IntToStr(AniGIF1->Frame);
- //设置文本显示
- ScrollBar1->Max=AniGIF1->Frames;
- ScrollBar1->Min=0;
- //设置滚动条参数
- Edit5->Text=OpenDialog1->FileName;
- Button2->Enabled=false;
- Button3->Enabled=false;
- //设置按钮有效状态
- }
- //---------------------------------------------------------------------------