home *** CD-ROM | disk | FTP | other *** search
/ PC PowerPlay 58 / pcpp58a.iso / extras / quake 3 source / Q3A_ToolSource.exe / Main / WaveOpen.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  2001-01-02  |  1.7 KB  |  78 lines

  1. // WaveOpen.cpp : implementation file
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "Radiant.h"
  6. #include "WaveOpen.h"
  7. #include "mmsystem.h"
  8.  
  9. #ifdef _DEBUG
  10. #define new DEBUG_NEW
  11. #undef THIS_FILE
  12. static char THIS_FILE[] = __FILE__;
  13. #endif
  14.  
  15. /////////////////////////////////////////////////////////////////////////////
  16. // CWaveOpen
  17.  
  18. IMPLEMENT_DYNAMIC(CWaveOpen, CFileDialog)
  19.  
  20. CWaveOpen::CWaveOpen(BOOL bOpenFileDialog, LPCTSTR lpszDefExt, LPCTSTR lpszFileName,
  21.         DWORD dwFlags, LPCTSTR lpszFilter, CWnd* pParentWnd) :
  22.         CFileDialog(bOpenFileDialog, lpszDefExt, lpszFileName, dwFlags, lpszFilter, pParentWnd)
  23. {
  24.   m_ofn.Flags |= (OFN_EXPLORER | OFN_ENABLETEMPLATE);
  25.   m_ofn.lpTemplateName = MAKEINTRESOURCE(IDD_PLAYWAVE);
  26. }
  27.  
  28.  
  29. BEGIN_MESSAGE_MAP(CWaveOpen, CFileDialog)
  30.     //{{AFX_MSG_MAP(CWaveOpen)
  31.     ON_BN_CLICKED(IDC_BTN_PLAY, OnBtnPlay)
  32.     //}}AFX_MSG_MAP
  33. END_MESSAGE_MAP()
  34.  
  35.  
  36. void CWaveOpen::OnFileNameChange()
  37. {
  38.   CString str = GetPathName();
  39.   str.MakeLower();
  40.   CWnd *pWnd = GetDlgItem(IDC_BTN_PLAY);
  41.   if (pWnd == NULL)
  42.   {
  43.     return;
  44.   }
  45.   if (str.Find(".wav") >= 0)
  46.   {
  47.     pWnd->EnableWindow(TRUE);
  48.   }
  49.   else
  50.   {
  51.     pWnd->EnableWindow(FALSE);
  52.   }
  53. }
  54.  
  55. void CWaveOpen::OnBtnPlay() 
  56. {
  57.   sndPlaySound(NULL, NULL);
  58.   CString str = GetPathName();
  59.   if (str.GetLength() > 0)
  60.   {
  61.     sndPlaySound(str, SND_FILENAME | SND_ASYNC);
  62.   }
  63. }
  64.  
  65. BOOL CWaveOpen::OnInitDialog() 
  66. {
  67.     CFileDialog::OnInitDialog();
  68.     
  69.   CWnd *pWnd = GetDlgItem(IDC_BTN_PLAY);
  70.   if (pWnd != NULL)
  71.   {
  72.     pWnd->EnableWindow(FALSE);
  73.   }
  74.     
  75.     return TRUE;  // return TRUE unless you set the focus to a control
  76.                   // EXCEPTION: OCX Property Pages should return FALSE
  77. }
  78.