Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

80 lines
2.3 KiB

  1. // DirectSoundFXGarglePage.cpp : Implementation of CDirectSoundFXGarglePage
  2. #include "stdafx.h"
  3. #include "Dsdmoprp.h"
  4. #include "DirectSoundFXGarglePage.h"
  5. /////////////////////////////////////////////////////////////////////////////
  6. // CDirectSoundFXGarglePage
  7. const CRadioChoice::ButtonEntry g_rgWaveButtons[] =
  8. {
  9. IDC_RADIO_TRIANGLE, DSFXGARGLE_WAVE_TRIANGLE,
  10. IDC_RADIO_SQUARE, DSFXGARGLE_WAVE_SQUARE,
  11. 0
  12. };
  13. CDirectSoundFXGarglePage::CDirectSoundFXGarglePage()
  14. : m_radioWaveform(g_rgWaveButtons)
  15. {
  16. m_dwTitleID = IDS_TITLEDirectSoundFXGarglePage;
  17. m_dwHelpFileID = IDS_HELPFILEDirectSoundFXGarglePage;
  18. m_dwDocStringID = IDS_DOCSTRINGDirectSoundFXGarglePage;
  19. m_rgpHandlers[0] = &m_sliderRate;
  20. m_rgpHandlers[1] = &m_radioWaveform;
  21. m_rgpHandlers[2] = NULL;
  22. }
  23. STDMETHODIMP CDirectSoundFXGarglePage::SetObjects(ULONG nObjects, IUnknown **ppUnk)
  24. {
  25. if (nObjects < 1 || nObjects > 1)
  26. return E_UNEXPECTED;
  27. HRESULT hr = ppUnk[0]->QueryInterface(IID_IDirectSoundFXGargle, reinterpret_cast<void**>(&m_IDSFXGargle));
  28. return hr;
  29. }
  30. STDMETHODIMP CDirectSoundFXGarglePage::Apply(void)
  31. {
  32. if (!m_IDSFXGargle)
  33. return E_UNEXPECTED;
  34. DSFXGargle dsfxgargle;
  35. ZeroMemory(&dsfxgargle, sizeof(DSFXGargle));
  36. dsfxgargle.dwRateHz = static_cast<DWORD>(m_sliderRate.GetValue());
  37. dsfxgargle.dwWaveShape = m_radioWaveform.GetChoice(*this);
  38. HRESULT hr = m_IDSFXGargle->SetAllParameters(&dsfxgargle);
  39. if (FAILED(hr))
  40. return hr;
  41. SetDirty(FALSE);
  42. return S_OK;
  43. }
  44. LRESULT CDirectSoundFXGarglePage::OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
  45. {
  46. if (!m_IDSFXGargle)
  47. return 1;
  48. DSFXGargle dsfxgargle;
  49. ZeroMemory(&dsfxgargle, sizeof(DSFXGargle));
  50. m_IDSFXGargle->GetAllParameters(&dsfxgargle);
  51. m_sliderRate.Init(GetDlgItem(IDC_SLIDER_Rate), GetDlgItem(IDC_EDIT_Rate), 1, 1000, true);
  52. m_sliderRate.SetValue(static_cast<float>(dsfxgargle.dwRateHz));
  53. m_radioWaveform.SetChoice(*this, dsfxgargle.dwWaveShape);
  54. return 1;
  55. }
  56. LRESULT CDirectSoundFXGarglePage::OnControlMessage(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
  57. {
  58. LRESULT lr = MessageHandlerChain(m_rgpHandlers, uMsg, wParam, lParam, bHandled);
  59. if (bHandled)
  60. SetDirty(TRUE);
  61. return lr;
  62. }