123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124 |
- // AVIPlayerDlg.cpp : implementation file
- //
- #include "stdafx.h"
- #include "ylgl.h"
- #include "AVIPlayerDlg.h"
- #include "vfw.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- #pragma comment(lib, "VFW32.lib")
- /////////////////////////////////////////////////////////////////////////////
- // CAVIPlayerDlg dialog
- CAVIPlayerDlg::CAVIPlayerDlg(CWnd* pParent /*=NULL*/)
- : CDialog(CAVIPlayerDlg::IDD, pParent)
- {
- //{{AFX_DATA_INIT(CAVIPlayerDlg)
- m_Path = _T("");
- //}}AFX_DATA_INIT
- }
- void CAVIPlayerDlg::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(CAVIPlayerDlg)
- DDX_Control(pDX, IDC_PAUSE, m_Pause);
- DDX_Control(pDX, IDC_PLAY, m_Play);
- //}}AFX_DATA_MAP
- }
- BEGIN_MESSAGE_MAP(CAVIPlayerDlg, CDialog)
- //{{AFX_MSG_MAP(CAVIPlayerDlg)
- ON_BN_CLICKED(IDC_PLAY, OnPlay)
- ON_BN_CLICKED(IDC_PAUSE, OnPause)
- ON_BN_CLICKED(IDC_STOP, OnStop)
- ON_WM_DESTROY()
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // CAVIPlayerDlg message handlers
- BOOL CAVIPlayerDlg::OnInitDialog()
- {
- CDialog::OnInitDialog();
-
- // TODO: Add extra initialization here
- m_Video = NULL;
- OnPlay();
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
- }
- void CAVIPlayerDlg::OnPlay()
- {
- // TODO: Add your control notification handler code here
- m_Video = NULL;
- if(m_Video == NULL)
- {
- m_Video = MCIWndCreate(this->GetSafeHwnd(),
- AfxGetInstanceHandle(),
- WS_CHILD | WS_VISIBLE|MCIWNDF_NOMENU,m_Path);
-
- }
- else
- {
- MCIWndHome(m_Video);
- }
- MCIWndPlay(m_Video);
- Pause = FALSE;
- m_Play.EnableWindow(FALSE);
-
- CRect rc,rc2;
- ::GetWindowRect (m_Video, &rc);
- ScreenToClient(rc);
- GetClientRect (&rc2);
- int w=rc.Width ();
- int h=rc.Height ();
- rc.left +=(rc2.Width ()-rc.Width ())/2;
- rc.top +=(rc2.Height ()-rc.Height ())/2;
- rc.right =rc.left +w;
- rc.bottom =rc.top +h;
- ::MoveWindow (m_Video, rc.left , rc.top , rc.Width (), rc.Height (), 0);
- }
- void CAVIPlayerDlg::OnPause()
- {
- // TODO: Add your control notification handler code here
- if(Pause)
- {
- m_Pause.SetWindowText("Pause");
- MCIWndResume(m_Video);
- Pause = FALSE;
- }
- else
- {
- m_Pause.SetWindowText("UnPause");
- MCIWndPause(m_Video);
- Pause = TRUE;
- }
- }
- void CAVIPlayerDlg::OnStop()
- {
- // TODO: Add your control notification handler code here
- MCIWndStop(m_Video);
- if(m_Video !=NULL)
- {
- MCIWndDestroy(m_Video);
- }
- m_Play.EnableWindow(TRUE);
- }
- void CAVIPlayerDlg::OnDestroy()
- {
- if(m_Video !=NULL)
- {
- MCIWndDestroy(m_Video);
- }
- CDialog::OnDestroy();
- }
|