WaveOpen.cpp 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. /*
  2. ===========================================================================
  3. Copyright (C) 1999-2005 Id Software, Inc.
  4. This file is part of Quake III Arena source code.
  5. Quake III Arena source code is free software; you can redistribute it
  6. and/or modify it under the terms of the GNU General Public License as
  7. published by the Free Software Foundation; either version 2 of the License,
  8. or (at your option) any later version.
  9. Quake III Arena source code is distributed in the hope that it will be
  10. useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with Foobar; if not, write to the Free Software
  15. Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  16. ===========================================================================
  17. */
  18. // WaveOpen.cpp : implementation file
  19. //
  20. #include "stdafx.h"
  21. #include "Radiant.h"
  22. #include "WaveOpen.h"
  23. #include "mmsystem.h"
  24. #ifdef _DEBUG
  25. #define new DEBUG_NEW
  26. #undef THIS_FILE
  27. static char THIS_FILE[] = __FILE__;
  28. #endif
  29. /////////////////////////////////////////////////////////////////////////////
  30. // CWaveOpen
  31. IMPLEMENT_DYNAMIC(CWaveOpen, CFileDialog)
  32. CWaveOpen::CWaveOpen(BOOL bOpenFileDialog, LPCTSTR lpszDefExt, LPCTSTR lpszFileName,
  33. DWORD dwFlags, LPCTSTR lpszFilter, CWnd* pParentWnd) :
  34. CFileDialog(bOpenFileDialog, lpszDefExt, lpszFileName, dwFlags, lpszFilter, pParentWnd)
  35. {
  36. m_ofn.Flags |= (OFN_EXPLORER | OFN_ENABLETEMPLATE);
  37. m_ofn.lpTemplateName = MAKEINTRESOURCE(IDD_PLAYWAVE);
  38. }
  39. BEGIN_MESSAGE_MAP(CWaveOpen, CFileDialog)
  40. //{{AFX_MSG_MAP(CWaveOpen)
  41. ON_BN_CLICKED(IDC_BTN_PLAY, OnBtnPlay)
  42. //}}AFX_MSG_MAP
  43. END_MESSAGE_MAP()
  44. void CWaveOpen::OnFileNameChange()
  45. {
  46. CString str = GetPathName();
  47. str.MakeLower();
  48. CWnd *pWnd = GetDlgItem(IDC_BTN_PLAY);
  49. if (pWnd == NULL)
  50. {
  51. return;
  52. }
  53. if (str.Find(".wav") >= 0)
  54. {
  55. pWnd->EnableWindow(TRUE);
  56. }
  57. else
  58. {
  59. pWnd->EnableWindow(FALSE);
  60. }
  61. }
  62. void CWaveOpen::OnBtnPlay()
  63. {
  64. sndPlaySound(NULL, NULL);
  65. CString str = GetPathName();
  66. if (str.GetLength() > 0)
  67. {
  68. sndPlaySound(str, SND_FILENAME | SND_ASYNC);
  69. }
  70. }
  71. BOOL CWaveOpen::OnInitDialog()
  72. {
  73. CFileDialog::OnInitDialog();
  74. CWnd *pWnd = GetDlgItem(IDC_BTN_PLAY);
  75. if (pWnd != NULL)
  76. {
  77. pWnd->EnableWindow(FALSE);
  78. }
  79. return TRUE; // return TRUE unless you set the focus to a control
  80. // EXCEPTION: OCX Property Pages should return FALSE
  81. }