home *** CD-ROM | disk | FTP | other *** search
/ Game Audio Programming / GameAudioProgramming.iso / Game_Audio / AudioTest / AudioTestDlg.cpp < prev    next >
C/C++ Source or Header  |  2002-06-29  |  5KB  |  226 lines

  1. /***********************************************************\
  2. Copyright (C) James Boer, 2002. 
  3. All rights reserved worldwide.
  4.  
  5. This software is provided "as is" without express or implied
  6. warranties. You may freely copy and compile this source into
  7. applications you distribute provided that the copyright text
  8. below is included in the resulting source code, for example:
  9. "Portions Copyright (C) James Boer, 2002"
  10. \***********************************************************/
  11.  
  12. #include "stdafx.h"
  13. #include "AudioTest.h"
  14. #include "AudioTestDlg.h"
  15. #include "Audio.h"
  16.  
  17. #include "EAXBuffer.h"
  18. #include "EAXListener.h"
  19. #include "ZoomFX.h"
  20.  
  21. #include "System.h"
  22. #include "Sound2D.h"
  23. #include "Sound3D.h"
  24. #include "Segment.h"
  25. #include "Listener.h"
  26. #include "SoundScript.h"
  27. #include "MusicScript.h"
  28.  
  29.  
  30.  
  31. #ifdef _DEBUG
  32. #define new DEBUG_NEW
  33. #undef THIS_FILE
  34. static char THIS_FILE[] = __FILE__;
  35. #endif
  36.  
  37. /////////////////////////////////////////////////////////////////////////////
  38. // CAboutDlg dialog used for App About
  39.  
  40. class CAboutDlg : public CDialog
  41. {
  42. public:
  43.     CAboutDlg();
  44.  
  45. // Dialog Data
  46.     //{{AFX_DATA(CAboutDlg)
  47.     enum { IDD = IDD_ABOUTBOX };
  48.     //}}AFX_DATA
  49.  
  50.     // ClassWizard generated virtual function overrides
  51.     //{{AFX_VIRTUAL(CAboutDlg)
  52.     protected:
  53.     virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
  54.     //}}AFX_VIRTUAL
  55.  
  56. // Implementation
  57. protected:
  58.     //{{AFX_MSG(CAboutDlg)
  59.     //}}AFX_MSG
  60.     DECLARE_MESSAGE_MAP()
  61. };
  62.  
  63. CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
  64. {
  65.     //{{AFX_DATA_INIT(CAboutDlg)
  66.     //}}AFX_DATA_INIT
  67. }
  68.  
  69. void CAboutDlg::DoDataExchange(CDataExchange* pDX)
  70. {
  71.     CDialog::DoDataExchange(pDX);
  72.     //{{AFX_DATA_MAP(CAboutDlg)
  73.     //}}AFX_DATA_MAP
  74. }
  75.  
  76. BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
  77.     //{{AFX_MSG_MAP(CAboutDlg)
  78.         // No message handlers
  79.     //}}AFX_MSG_MAP
  80. END_MESSAGE_MAP()
  81.  
  82. /////////////////////////////////////////////////////////////////////////////
  83. // CAudioTestDlg dialog
  84.  
  85. CAudioTestDlg::CAudioTestDlg(CWnd* pParent /*=NULL*/)
  86.     : CPropertySheet("Audio Test", pParent, 0)
  87. {
  88.     //{{AFX_DATA_INIT(CAudioTestDlg)
  89.         // NOTE: the ClassWizard will add member initialization here
  90.     //}}AFX_DATA_INIT
  91.     // Note that LoadIcon does not require a subsequent DestroyIcon in Win32
  92.     m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
  93.  
  94.     m_pSystem = 0;
  95.     m_pSound2D = 0;
  96.     m_pSound3D = 0;
  97.     m_pListener = 0;
  98.     m_pSoundScript = 0;
  99.     m_pSegment = 0;
  100.     m_pMusicScript = 0;
  101.     m_pCDAudio = 0;
  102.     m_pEAXBuffer = 0;
  103.     m_pEAXListener = 0;
  104.     m_pZoomFX = 0;
  105.  
  106. }
  107.  
  108. void CAudioTestDlg::DoDataExchange(CDataExchange* pDX)
  109. {
  110.     CPropertySheet::DoDataExchange(pDX);
  111.     //{{AFX_DATA_MAP(CAudioTestDlg)
  112.         // NOTE: the ClassWizard will add DDX and DDV calls here
  113.     //}}AFX_DATA_MAP
  114. }
  115.  
  116. BEGIN_MESSAGE_MAP(CAudioTestDlg, CPropertySheet)
  117.     //{{AFX_MSG_MAP(CAudioTestDlg)
  118.     ON_WM_SYSCOMMAND()
  119.     ON_WM_PAINT()
  120.     ON_WM_QUERYDRAGICON()
  121.     ON_WM_DESTROY()
  122.     //}}AFX_MSG_MAP
  123. END_MESSAGE_MAP()
  124.  
  125. /////////////////////////////////////////////////////////////////////////////
  126. // CAudioTestDlg message handlers
  127.  
  128. BOOL CAudioTestDlg::OnInitDialog()
  129. {
  130.     CPropertySheet::OnInitDialog();
  131.  
  132.     // Add "About..." menu item to system menu.
  133.  
  134.     // IDM_ABOUTBOX must be in the system command range.
  135.     ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
  136.     ASSERT(IDM_ABOUTBOX < 0xF000);
  137.  
  138.     CMenu* pSysMenu = GetSystemMenu(FALSE);
  139.     if (pSysMenu != NULL)
  140.     {
  141.         CString strAboutMenu;
  142.         strAboutMenu.LoadString(IDS_ABOUTBOX);
  143.         if (!strAboutMenu.IsEmpty())
  144.         {
  145.             pSysMenu->AppendMenu(MF_SEPARATOR);
  146.             pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
  147.         }
  148.     }
  149.  
  150.     // Set the icon for this dialog.  The framework does this automatically
  151.     //  when the application's main window is not a dialog
  152.     SetIcon(m_hIcon, TRUE);            // Set big icon
  153.     SetIcon(m_hIcon, FALSE);        // Set small icon
  154.     
  155.     return TRUE;  // return TRUE  unless you set the focus to a control
  156. }
  157.  
  158. void CAudioTestDlg::OnSysCommand(UINT nID, LPARAM lParam)
  159. {
  160.     if ((nID & 0xFFF0) == IDM_ABOUTBOX)
  161.     {
  162.         CAboutDlg dlgAbout;
  163.         dlgAbout.DoModal();
  164.     }
  165.     else
  166.     {
  167.         CPropertySheet::OnSysCommand(nID, lParam);
  168.     }
  169. }
  170.  
  171. // If you add a minimize button to your dialog, you will need the code below
  172. //  to draw the icon.  For MFC applications using the document/view model,
  173. //  this is automatically done for you by the framework.
  174.  
  175. void CAudioTestDlg::OnPaint() 
  176. {
  177.     if (IsIconic())
  178.     {
  179.         CPaintDC dc(this); // device context for painting
  180.  
  181.         SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
  182.  
  183.         // Center icon in client rectangle
  184.         int cxIcon = GetSystemMetrics(SM_CXICON);
  185.         int cyIcon = GetSystemMetrics(SM_CYICON);
  186.         CRect rect;
  187.         GetClientRect(&rect);
  188.         int x = (rect.Width() - cxIcon + 1) / 2;
  189.         int y = (rect.Height() - cyIcon + 1) / 2;
  190.  
  191.         // Draw the icon
  192.         dc.DrawIcon(x, y, m_hIcon);
  193.     }
  194.     else
  195.     {
  196.         CPropertySheet::OnPaint();
  197.     }
  198. }
  199.  
  200. // The system calls this to obtain the cursor to display while the user drags
  201. //  the minimized window.
  202. HCURSOR CAudioTestDlg::OnQueryDragIcon()
  203. {
  204.     return (HCURSOR) m_hIcon;
  205. }
  206.  
  207.  
  208. void CAudioTestDlg::OnDestroy() 
  209. {
  210.     CPropertySheet::OnDestroy();
  211.     
  212.     if(m_pEAXBuffer)
  213.     {
  214.         m_pEAXBuffer->DestroyWindow();
  215.     }
  216.     if(m_pEAXListener)
  217.     {
  218.         m_pEAXListener->DestroyWindow();
  219.     }
  220.     if(m_pZoomFX)
  221.     {
  222.         m_pZoomFX->DestroyWindow();
  223.     }
  224.     
  225. }
  226.