⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 maindemo_.cpp

📁 toi co the nghe nhac bang choung trinh nay phgan 2
💻 CPP
📖 第 1 页 / 共 2 页
字号:
//(((((((((((((((((((((((((((((((((((((((O))))))))))))))))))))))))))))))))))))))//
//                                                                              //
//                                TActiveMovie demo                             //
//                          Copyright (c) 2003 Datastead                        //
//                               All rights reserved.                           //
//                                                                              //
//                          contact: support@Datastead.com                      //
//                        support: http://www.Datastead.com                     //
//                                                                              //
//(((((((((((((((((((((((((((((((((((((((O))))))))))))))))))))))))))))))))))))))//

//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop

#include "MainDemo_.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma link "AMovie"
#pragma link "AMovie"
#pragma resource "*.dfm"
TForm1 *Form1;
TForm *StillForm;
TImage *StillImage;

//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
        : TForm(Owner)
{
}

//---------------------------------------------------------------------------
void __fastcall TForm1::FormCreate(TObject *Sender)
//---------------------------------------------------------------------------
{
   SetAnchorsIfNotD3OrBCB3();

   if (FileExists ("demo.mpeg")) {
      Edit1->Text = ExpandFileName ("demo.mpeg");
   }
   CheckBox2->Checked = ActiveMovie1->ShowControls;
   CheckBox3->Checked = ActiveMovie1->DisplayLogo;
   CheckBox4->Checked = ActiveMovie1->AutoStart;
   CheckBox5->Checked = ActiveMovie1->ShowScrollBars;
   CheckBox6->Checked = ActiveMovie1->Visible;
   TrackBar1Change (TrackBar1);
}

//---------------------------------------------------------------------------
void __fastcall TForm1::ActiveMovie1PositionChange(TObject *Sender,
      double OldTimePosition, double NewTimePosition,
      DWORD OldFramePosition, DWORD NewFramePosition)
//---------------------------------------------------------------------------
{
   // DON'T FORGET TO CHECK IF TOTALTIME > 0 to divide by TotalTime, because this value
   // may be 0 if the total time is unknown (e.g. with stream medias, like web radios).
   if (ActiveMovie1->TotalTime > 0) {
      if (TrackBar5->Tag == 0) {
         TrackBar5->Tag = 1;
         TrackBar5->Position = NewTimePosition * TrackBar5->Max / ActiveMovie1->TotalTime;
         TrackBar5->Tag = 0;
      }
   }
}

//---------------------------------------------------------------------------
void __fastcall TForm1::ActiveMovie1OpenStateChange(TObject *Sender,
      int OldState, int NewState)
//---------------------------------------------------------------------------
{
   if (NewState == nsOpen) {
      BitBtn1->Enabled = True;
   }
   else {
      BitBtn1->Enabled = False;
   }
}

//---------------------------------------------------------------------------
void __fastcall TForm1::ActiveMovie1Error(TObject *Sender, int ErrorCode,
      AnsiString ErrorMessage)
//---------------------------------------------------------------------------
{
//   StatusBar1.Color := clRed;
   Beep (500, 300);
 //  StatusBar1.ParentColor := True;
   TVarRec v[] = {ErrorCode, ErrorMessage};
   StatusBar1->SimpleText  = " " + Format (" Error %08x: %s", v, (ARRAYSIZE(v) - 1));
}

//---------------------------------------------------------------------------
void __fastcall TForm1::ActiveMovie1FullScreenKeyPress(TObject *Sender,
      WORD Key, TShiftState Shift)
//---------------------------------------------------------------------------
{
   const int F2 = 113;
   const int F3 = 114;
   const int F4 = 115;
   const int F5 = 116;
   const int F6 = 117;
   const int F7 = 118;
   const int F8 = 119;
   const int F11 = 122;
   const int F12 = 123;

   int VolumeStep;

   VolumeStep = 100;
   switch (Key) {
      case F2: ActiveMovie1->Play (); break;
      case F3: ActiveMovie1->Pause (); break;
      case F4: ActiveMovie1->Stop (); break;

      case F5: ActiveMovie1->FastForward2 (10); break;

      case F6: ActiveMovie1->FastReverse2 (10); break;

      case F7: ActiveMovie1->Rate = ActiveMovie1->Rate + 0.3; break;

      case F8: ActiveMovie1->Rate = ActiveMovie1->Rate - 0.3; break;

      case F11: if ((ActiveMovie1->Volume + VolumeStep) <= 0) {
                   ActiveMovie1->Volume = ActiveMovie1->Volume + VolumeStep;
                } else {
                   ActiveMovie1->Volume = 0;
                } break;

      case F12: if ((ActiveMovie1->Volume + VolumeStep) > -10000) {
                   ActiveMovie1->Volume = ActiveMovie1->Volume - VolumeStep;
                } else {
                   ActiveMovie1->Volume = - 10000;
                } break;
   }
}

//---------------------------------------------------------------------------
void __fastcall TForm1::BitBtn1Click(TObject *Sender)
//---------------------------------------------------------------------------
{
   if (StillForm == NULL) {
      Application->CreateForm (__classid(TForm), &StillForm);
      StillForm->HorzScrollBar->Visible = false;
      StillForm->VertScrollBar->Visible = false;
      StillForm->Position = poDefault;
      StillForm->FormStyle = fsStayOnTop;
      StillImage = new TImage (StillForm);
      StillImage->Parent = StillForm;
   }
   if (ActiveMovie1->CaptureFrameToImage (StillImage)) {
      StillForm->ClientWidth = StillImage->Width;
      StillForm->ClientHeight = StillImage->Height;
      StillForm->Show();
   }
}

//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
//---------------------------------------------------------------------------
{
   ActiveMovie1->FileName = Edit1->Text;
   ActiveMovie1->Open();
}

//---------------------------------------------------------------------------
void __fastcall TForm1::Button2Click(TObject *Sender)
//---------------------------------------------------------------------------
{
   ActiveMovie1->Close ();
}

//---------------------------------------------------------------------------
void __fastcall TForm1::Button3Click(TObject *Sender)
//---------------------------------------------------------------------------
{
   Edit1->Text = "http://www.Datastead.com/amovie/demo.mpeg";
   ActiveMovie1->FileName = Edit1->Text;
   ActiveMovie1->Open();
}

//---------------------------------------------------------------------------
void __fastcall TForm1::Button4Click(TObject *Sender)
//---------------------------------------------------------------------------
{
   TrackBar2->Position = 400;
   TrackBar2->OnChange (this);
}

//---------------------------------------------------------------------------
void __fastcall TForm1::Button5Click(TObject *Sender)
//---------------------------------------------------------------------------
{
   TrackBar6->Position = 20; // the middle between Min and Max
   TrackBar6Change (this);
   TrackBar7->Position = 20;
   TrackBar7Change (this);
}

//---------------------------------------------------------------------------
void __fastcall TForm1::Button6Click(TObject *Sender)
//---------------------------------------------------------------------------
{
   TrackBar3->Position = 100;
}

//---------------------------------------------------------------------------
void __fastcall TForm1::SpeedButton1Click(TObject *Sender)
//---------------------------------------------------------------------------
{
   OpenDialog1->Filter = "video clips";
   OpenDialog1->FileName = "*.mpg;*.mpeg;*.avi;*.wav;*.mp3;*.asf;*.wmv";
   if (OpenDialog1->Execute()) {
      Edit1->Text = OpenDialog1->FileName;
      ActiveMovie1->FileName = Edit1->Text;
      ActiveMovie1->Open();
   }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -