home *** CD-ROM | disk | FTP | other *** search
/ Large Pack of OldSkool DOS MOD Trackers / beaversweeper_v101.zip / src / PropPageSound.cpp < prev    next >
C/C++ Source or Header  |  2003-01-06  |  4KB  |  130 lines

  1. // PropPageSound.cpp : implementation file
  2. //
  3.  
  4.  
  5.  
  6. #include "stdafx.h"
  7. #include "tracker.h"
  8. #include "PropPageSound.h"
  9. #include "Configuration.h"
  10. #include <mmsystem.h>
  11. #include "isPlayer.h"
  12.  
  13.  
  14. #ifdef _DEBUG
  15. #define new DEBUG_NEW
  16. #undef THIS_FILE
  17. static char THIS_FILE[] = __FILE__;
  18. #endif
  19.  
  20. /////////////////////////////////////////////////////////////////////////////
  21. // CPropPageSound property page
  22.  
  23. IMPLEMENT_DYNCREATE(CPropPageSound, CPropertyPage)
  24.  
  25. CPropPageSound::CPropPageSound() : CPropertyPage(CPropPageSound::IDD)
  26. {
  27.     //{{AFX_DATA_INIT(CPropPageSound)
  28.     m_latency = 0;
  29.     //}}AFX_DATA_INIT
  30. }
  31.  
  32. CPropPageSound::~CPropPageSound()
  33. {
  34. }
  35.  
  36. void CPropPageSound::DoDataExchange(CDataExchange* pDX)
  37. {
  38.     CPropertyPage::DoDataExchange(pDX);
  39.     //{{AFX_DATA_MAP(CPropPageSound)
  40.     DDX_Control(pDX, IDC_COMBO1, m_threadpriority);
  41.     DDX_Control(pDX, IDC_SPIN1, m_latspinner);
  42.     DDX_Text(pDX, IDC_EDIT1, m_latency);
  43.     //}}AFX_DATA_MAP
  44. }
  45.  
  46.  
  47. BEGIN_MESSAGE_MAP(CPropPageSound, CPropertyPage)
  48.     //{{AFX_MSG_MAP(CPropPageSound)
  49.     ON_EN_CHANGE(IDC_EDIT1, OnChangeEdit1)
  50.     ON_CBN_SELCHANGE(IDC_COMBO1, OnSelchangeCombo1)
  51.     //}}AFX_MSG_MAP
  52. END_MESSAGE_MAP()
  53.  
  54. /////////////////////////////////////////////////////////////////////////////
  55. // CPropPageSound message handlers
  56.  
  57. void CPropPageSound::OnChangeEdit1() 
  58. {
  59.     // TODO: If this is a RICHEDIT control, the control will not
  60.     // send this notification unless you override the CPropertyPage::OnInitDialog()
  61.     // function and call CRichEditCtrl().SetEventMask()
  62.     // with the ENM_CHANGE flag ORed into the mask.
  63.     
  64.     // TODO: Add your control notification handler code here
  65.     SetModified();
  66.     
  67. }
  68.  
  69. BOOL CPropPageSound::OnInitDialog() 
  70. {
  71.     CPropertyPage::OnInitDialog();
  72.     
  73.     // TODO: Add extra initialization here
  74.     m_latspinner.SetRange( 1, 1000 );
  75.     m_latency = CONFIGURATION_GETDWORD( _T("dsound"), _T("latency"), 400 );
  76.     m_latspinner.SetBuddy( GetDlgItem( IDC_EDIT1 ) );                
  77.  
  78.     m_threadpriority.InsertString( 0, _T("Normal") );
  79.     m_threadpriority.InsertString( 1, _T("Above normal") );
  80.     m_threadpriority.InsertString( 2, _T("Highest") );
  81.     m_threadpriority.InsertString( 3, _T("Time critical") );
  82.     m_threadpriority.SetCurSel( CONFIGURATION_GETDWORD( _T("dsound"), _T("threadpriority"), 0 ) );
  83.     
  84.     UpdateData( FALSE );
  85.         
  86.     return TRUE;  // return TRUE unless you set the focus to a control
  87.                   // EXCEPTION: OCX Property Pages should return FALSE
  88. }
  89.  
  90. // lista
  91. extern isPlayer *g_docPlayerList[16];
  92.  
  93. BOOL CPropPageSound::OnApply() 
  94. {
  95.     // TODO: Add your specialized code here and/or call the base class
  96.     UpdateData( TRUE );
  97.     CONFIGURATION_SETDWORD( _T("dsound"), _T("latency"), m_latency );
  98.     CONFIGURATION_SETDWORD( _T("dsound"), _T("threadpriority"), m_threadpriority.GetCurSel( ) );
  99.  
  100.     for (int i=0;i<16;i++)
  101.         if (g_docPlayerList[i]) {
  102.             g_docPlayerList[i]->SetLatency( m_latency );
  103.             HANDLE thread = g_docPlayerList[i]->GetThreadHandle();
  104.             switch ( m_threadpriority.GetCurSel() ) {
  105.                 case 0:
  106.                     SetThreadPriority( thread, THREAD_PRIORITY_NORMAL );
  107.                     break;
  108.                 case 1:
  109.                     SetThreadPriority( thread, THREAD_PRIORITY_ABOVE_NORMAL );
  110.                     break;
  111.                 case 2:
  112.                     SetThreadPriority( thread, THREAD_PRIORITY_HIGHEST );
  113.                     break;
  114.                 case 3:
  115.                     SetThreadPriority( thread, THREAD_PRIORITY_TIME_CRITICAL );
  116.                     break;
  117.             }
  118.         }
  119.  
  120.     
  121.     return CPropertyPage::OnApply();
  122. }
  123.  
  124. void CPropPageSound::OnSelchangeCombo1() 
  125. {
  126.     // TODO: Add your control notification handler code here
  127.     SetModified();
  128.     
  129. }
  130.