?? mainform.cpp
字號:
//---------------------------------------------------------------------------
#include <vcl\vcl.h>
#pragma hdrstop
#include "MAINFORM.h"
//---------------------------------------------------------------------------
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
// pop up the common file dialog
if(OpenDialog1->Execute())
{
MediaPlayer1->FileName=OpenDialog1->FileName;
// Open raises an exception if something acts up. use a try
// catch block to detect an error.
try
{
MediaPlayer1->Open();
}
catch (...)
{
// should Application->Terminate if an exception occurs
Application->MessageBox("Error opening file",mtWarning,MB_ICONWARNING|MB_OK);
}
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::MediaPlayer1Click(TObject *Sender, TMPBtnType Button,
bool &DoDefault)
{
// find out which button was pressed, if Play, then start
// the timer, if Stop the disable it. The timer will just
// run if pause was pushed
if(Button == btPlay)
Timer1->Enabled = true;
else if (Button == btStop)
Timer1->Enabled = false;
// set DoDefault to true so the MediaPlayer will do
// what it normally does for the button press
DoDefault = true;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Timer1Timer(TObject *Sender)
{
// update position using properties of TMediaPlayer need to cast because
// TProgressBar is 16 bits while TMediaPlayer is 32. Division ensures that
// number will be between 0 and 100
ProgressBar1->Position = (TProgressRange)(MediaPlayer1->Position * 100 /
MediaPlayer1->Length);
// if media has finished then shut off the timer
if(ProgressBar1->Position == 100)
Timer1->Enabled = false;
}
//---------------------------------------------------------------------------
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -