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

  1. // PropPageMidi.cpp : implementation file
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "tracker.h"
  6. #include "PropPageMidi.h"
  7. #include "instrEditor.h"
  8. #include "MIDIInput.h"
  9. #include "Globals.h"
  10. #include "Configuration.h"
  11.  
  12.  
  13. #ifdef _DEBUG
  14. #define new DEBUG_NEW
  15. #undef THIS_FILE
  16. static char THIS_FILE[] = __FILE__;
  17. #endif
  18.  
  19. /////////////////////////////////////////////////////////////////////////////
  20. // CPropPageMidi property page
  21.  
  22. IMPLEMENT_DYNCREATE(CPropPageMidi, CPropertyPage)
  23.  
  24. CPropPageMidi::CPropPageMidi() : CPropertyPage(CPropPageMidi::IDD)
  25. {
  26.     //{{AFX_DATA_INIT(CPropPageMidi)
  27.         // NOTE: the ClassWizard will add member initialization here
  28.     //}}AFX_DATA_INIT
  29. }
  30.  
  31. CPropPageMidi::~CPropPageMidi()
  32. {
  33. }
  34.  
  35. void CPropPageMidi::DoDataExchange(CDataExchange* pDX)
  36. {
  37.     CPropertyPage::DoDataExchange(pDX);
  38.     //{{AFX_DATA_MAP(CPropPageMidi)
  39.     DDX_Control(pDX, IDC_COMBO1, m_mididevice);
  40.     //}}AFX_DATA_MAP
  41. }
  42.  
  43.  
  44. BEGIN_MESSAGE_MAP(CPropPageMidi, CPropertyPage)
  45.     //{{AFX_MSG_MAP(CPropPageMidi)
  46.     ON_WM_HSCROLL()
  47.     ON_CBN_SELCHANGE(IDC_COMBO1, OnSelchangeCombo1)
  48.     //}}AFX_MSG_MAP
  49. END_MESSAGE_MAP()
  50.  
  51. /////////////////////////////////////////////////////////////////////////////
  52. // CPropPageMidi message handlers
  53.  
  54. void CPropPageMidi::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar) 
  55. {
  56.     // TODO: Add your message handler code here and/or call default
  57.     
  58.     CPropertyPage::OnHScroll(nSBCode, nPos, pScrollBar);
  59. }
  60.  
  61. BOOL CPropPageMidi::OnInitDialog() 
  62. {
  63.     CPropertyPage::OnInitDialog();
  64.     
  65.  
  66.     // SlΣng in alla MIDI-devices i listan 
  67.     m_mididevice.Clear();
  68.     m_mididevice.InsertString( 0, _T("-- Disabled --") );
  69.  
  70.     UINT devCount = midiOutGetNumDevs();
  71.     for (UINT i=0;i<devCount;i++) {
  72.         MIDIINCAPS caps;
  73.         if (MMSYSERR_NOERROR == midiInGetDevCaps( i, &caps, sizeof( MIDIINCAPS ) )) {
  74.             m_mididevice.InsertString( i + 1, caps.szPname );                        
  75.         }            
  76.     }
  77.  
  78.     m_mididevice.SetCurSel( g_midi_device );
  79.     
  80.     return TRUE;  // return TRUE unless you set the focus to a control
  81.                   // EXCEPTION: OCX Property Pages should return FALSE
  82. }
  83.  
  84. BOOL CPropPageMidi::OnApply() 
  85. {
  86.     // TODO: Add your specialized code here and/or call the base class
  87.     g_midi_device = m_mididevice.GetCurSel();
  88.     g_midi_input->stop();
  89.  
  90.     if (g_midi_device)  {
  91.         g_midi_input->start( g_midi_device - 1 );
  92.         CONFIGURATION_SETDWORD( _T("MIDI"), _T("Device"), g_midi_device );
  93.     }
  94.  
  95.     return CPropertyPage::OnApply();
  96. }
  97.  
  98. void CPropPageMidi::OnSelchangeCombo1() 
  99. {
  100.     // TODO: Add your control notification handler code here
  101.     SetModified(TRUE);
  102.     
  103. }
  104.