www.pudn.com > p1.rar > Unit1.~cpp
//--------------------------------------------------------------------------- #include#pragma hdrstop #include "Unit1.h" //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma resource "*.dfm" TForm1 *Form1; //--------------------------------------------------------------------------- __fastcall TForm1::TForm1(TComponent* Owner) : TForm(Owner) { } //--------------------------------------------------------------------------- void __fastcall TForm1::FormCreate(TObject *Sender) { MediaPlayer1->VisibleButtons< EnabledButtons< Display=AVIPanel; BtnPlay->Enabled=false; BtnPause->Enabled=false; BtnStop->Enabled=false; BtnNext->Enabled=false; BtnBack->Enabled=false; BtnStep->Enabled=false; BtnPrev->Enabled=false; BtnOpen->Enabled=true; ScrollBar1->Enabled= false; Timer1->Enabled=false; } //--------------------------------------------------------------------------- void __fastcall TForm1::Timer1Timer(TObject *Sender) { ScrollBar1->Position=MediaPlayer1->Position; LblLength->Caption="动画总帧数: "+ IntToStr(MediaPlayer1->Length); LblPos->Caption="动画当前帧: "+ IntToStr(MediaPlayer1->Position); if(MediaPlayer1->Position==MediaPlayer1->Length) BtnPlay->Enabled=false; } //--------------------------------------------------------------------------- void __fastcall TForm1::BtnOpenClick(TObject *Sender) { if(OpenDialog1->Execute()) { MediaPlayer1->FileName=OpenDialog1->FileName; MediaPlayer1->Open(); ScrollBar1->Min=0; ScrollBar1->Max=MediaPlayer1->Length; ScrollBar1->Enabled=true; BtnPlay->Enabled=true; tttt(); TForm2 * newform=new TForm2(this); newform->cdim=1; AVIFileInit(); newform->AviCreate(OpenDialog1->FileName); newform->AviRead(20); AVIFileExit(); StretchDIBits(Image1->Canvas->Handle, 0,0,newform->cx,newform->cy, 0,0,newform->cx,newform->cy, newform->pimagebuf,newform->pbitmapinfo, DIB_RGB_COLORS,SRCCOPY); newform->AviFileSave(OpenDialog1->FileName,"q2.avi"); MediaPlayer2->FileName="q2.avi"; MediaPlayer2->Display=ShowPanel; MediaPlayer2->Open(); MediaPlayer2->Play(); } } //--------------------------------------------------------------------------- void __fastcall TForm1::BtnPlayClick(TObject *Sender) { MediaPlayer1->Play(); BtnPause->Enabled=true; BtnStop->Enabled=true; BtnNext->Enabled=true; BtnBack->Enabled=true; BtnStep->Enabled=true; BtnPrev->Enabled=true; Timer1->Enabled =true; BtnPlay->Enabled=false; //AVIPanel->Height=MediaPlayer1->Height; //AVIPanel->Width =MediaPlayer1->Width; AVIPanel->Height=200; AVIPanel->Width =200; } //--------------------------------------------------------------------------- void __fastcall TForm1::ScrollBar1Scroll(TObject *Sender, TScrollCode ScrollCode, int &ScrollPos) { MediaPlayer1->Position=ScrollBar1->Position; BtnPlay->Enabled=true; } void TForm1::tttt() { ICINFO icinfo; for (int i=0; ICInfo(ICTYPE_VIDEO, i, &icinfo); i++) { //m_com1.AddString(_bstr_t(icinfo.szDescription)); //bstr_t(icinfo.szDescription); HIC hic = ICOpen(icinfo.fccType, icinfo.fccHandler, ICMODE_QUERY); AnsiString aaa=""; aaa+= (char)(icinfo.fccHandler); aaa+= (char)(icinfo.fccHandler>>8); aaa+= (char)(icinfo.fccHandler>>16); aaa+= (char)(icinfo.fccHandler>>24); for (t=0;t<128;t++) aaa+= icinfo.szDescription[t]; if (hic) { ICGetInfo(hic, &icinfo, sizeof(icinfo)); // Add it to the combo box. //m_com1.AddString(_bstr_t(icinfo.szDescription)); } } }