VocPlayerDlg.cpp
资源名称:VocPlay.zip [点击查看]
上传用户:zctools
上传日期:2013-04-03
资源大小:26k
文件大小:3k
源码类别:
多媒体编程
开发平台:
Visual C++
- // VocPlayerDlg.cpp : implementation file
- //
- #include "stdafx.h"
- #include "VocPlayer.h"
- #include "VocPlayerDlg.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // CVocPlayerDlg dialog
- CVocPlayerDlg::CVocPlayerDlg(CWnd* pParent /*=NULL*/)
- : CDialog(CVocPlayerDlg::IDD, pParent)
- {
- //{{AFX_DATA_INIT(CVocPlayerDlg)
- // NOTE: the ClassWizard will add member initialization here
- //}}AFX_DATA_INIT
- m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
- }
- void CVocPlayerDlg::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(CVocPlayerDlg)
- // NOTE: the ClassWizard will add DDX and DDV calls here
- //}}AFX_DATA_MAP
- }
- BEGIN_MESSAGE_MAP(CVocPlayerDlg, CDialog)
- //{{AFX_MSG_MAP(CVocPlayerDlg)
- ON_WM_PAINT()
- ON_WM_QUERYDRAGICON()
- ON_BN_CLICKED(IDC_BUTTON_BROWSE, OnButtonBrowse)
- ON_BN_CLICKED(IDC_BUTTON_PLAY, OnButtonPlay)
- //}}AFX_MSG_MAP
- ON_MESSAGE( MM_WOM_DONE, OnMMDone )
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // CVocPlayerDlg message handlers
- BOOL CVocPlayerDlg::OnInitDialog()
- {
- CDialog::OnInitDialog();
- SetIcon(m_hIcon, TRUE); // Set big icon
- SetIcon(m_hIcon, FALSE); // Set small icon
- // TODO: Add extra initialization here
- GetDlgItem( IDC_BUTTON_PLAY )->EnableWindow( false );
- return TRUE; // return TRUE unless you set the focus to a control
- }
- // If you add a minimize button to your dialog, you will need the code below
- // to draw the icon. For MFC applications using the document/view model,
- // this is automatically done for you by the framework.
- void CVocPlayerDlg::OnPaint()
- {
- if (IsIconic())
- {
- CPaintDC dc(this); // device context for painting
- SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
- // Center icon in client rectangle
- int cxIcon = GetSystemMetrics(SM_CXICON);
- int cyIcon = GetSystemMetrics(SM_CYICON);
- CRect rect;
- GetClientRect(&rect);
- int x = (rect.Width() - cxIcon + 1) / 2;
- int y = (rect.Height() - cyIcon + 1) / 2;
- // Draw the icon
- dc.DrawIcon(x, y, m_hIcon);
- }
- else
- {
- CDialog::OnPaint();
- }
- }
- HCURSOR CVocPlayerDlg::OnQueryDragIcon()
- {
- return (HCURSOR) m_hIcon;
- }
- void CVocPlayerDlg::OnButtonBrowse()
- {
- CFileDialog DlgFileOpen( true, "voc", NULL,
- OFN_PATHMUSTEXIST|OFN_LONGNAMES|OFN_HIDEREADONLY,
- "VOC Files (*.voc)|*.voc||",
- this );
- if ( DlgFileOpen.DoModal() != IDOK )
- return;
- Filename = DlgFileOpen.GetPathName();
- GetDlgItem( IDC_STATIC_FILENAME )->SetWindowText( Filename );
- GetDlgItem( IDC_BUTTON_PLAY )->EnableWindow( true );
- }
- void CVocPlayerDlg::OnButtonPlay()
- {
- CString Filename;
- GetDlgItem( IDC_STATIC_FILENAME )->GetWindowText( Filename );
- VocPlayer.Play( Filename, this );
- }
- void CVocPlayerDlg::OnMMDone( WPARAM, LPARAM )
- {
- VocPlayer.Reset();
- VocPlayer.Clear();
- }