00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #include "stdafx.h"
00026 #include "Radiant.h"
00027 #include "WaveOpen.h"
00028 #include "mmsystem.h"
00029
00030 #ifdef _DEBUG
00031 #define new DEBUG_NEW
00032 #undef THIS_FILE
00033 static char THIS_FILE[] = __FILE__;
00034 #endif
00035
00037
00038
00039 IMPLEMENT_DYNAMIC(CWaveOpen, CFileDialog)
00040
00041 CWaveOpen::CWaveOpen(BOOL bOpenFileDialog, LPCTSTR lpszDefExt, LPCTSTR lpszFileName,
00042 DWORD dwFlags, LPCTSTR lpszFilter, CWnd* pParentWnd) :
00043 CFileDialog(bOpenFileDialog, lpszDefExt, lpszFileName, dwFlags, lpszFilter, pParentWnd)
00044 {
00045 m_ofn.Flags |= (OFN_EXPLORER | OFN_ENABLETEMPLATE);
00046 m_ofn.lpTemplateName = MAKEINTRESOURCE(IDD_PLAYWAVE);
00047 }
00048
00049
00050 BEGIN_MESSAGE_MAP(CWaveOpen, CFileDialog)
00051
00052 ON_BN_CLICKED(IDC_BTN_PLAY, OnBtnPlay)
00053
00054 END_MESSAGE_MAP()
00055
00056
00057 void CWaveOpen::OnFileNameChange()
00058 {
00059 CString str = GetPathName();
00060 str.MakeLower();
00061 CWnd *pWnd = GetDlgItem(IDC_BTN_PLAY);
00062 if (pWnd == NULL)
00063 {
00064 return;
00065 }
00066 if (str.Find(".wav") >= 0)
00067 {
00068 pWnd->EnableWindow(TRUE);
00069 }
00070 else
00071 {
00072 pWnd->EnableWindow(FALSE);
00073 }
00074 }
00075
00076 void CWaveOpen::OnBtnPlay()
00077 {
00078 sndPlaySound(NULL, NULL);
00079 CString str = GetPathName();
00080 if (str.GetLength() > 0)
00081 {
00082 sndPlaySound(str, SND_FILENAME | SND_ASYNC);
00083 }
00084 }
00085
00086 BOOL CWaveOpen::OnInitDialog()
00087 {
00088 CFileDialog::OnInitDialog();
00089
00090 CWnd *pWnd = GetDlgItem(IDC_BTN_PLAY);
00091 if (pWnd != NULL)
00092 {
00093 pWnd->EnableWindow(FALSE);
00094 }
00095
00096 return TRUE;
00097
00098 }