home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the 3D Game Programming Gurus / gurus.iso / DirectX / dx9sdkcp.exe / SDK (C++) / Bin / DXUtils / Visual Studio 6.0 Wizards / AEDMOWiz.awx / TEMPLATE / CLASSNAMEPROP.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  2002-12-11  |  4.3 KB  |  174 lines

  1. //------------------------------------------------------------------------------
  2. // File: $$CLASS_NAME$$Prop.cpp
  3. //
  4. // Desc: Audio Effect DMO Wizard generated code - Implementation of
  5. //         $$CLASS_NAME$$Prop
  6. //
  7. // Copyright (c) Microsoft Corporation.  All rights reserved.
  8. //------------------------------------------------------------------------------
  9.  
  10. /////////////////////////////////////////////////////////////////////////////
  11. // TODO List: (Functions that are only partially implemented)
  12. //  - OnInitDialog()
  13. //    - Apply()
  14. //
  15. /////////////////////////////////////////////////////////////////////////////
  16.  
  17.  
  18. #include "stdafx.h"
  19.  
  20. #define _ATL_APARTMENT_THREADED
  21. #define _ATL_STATIC_REGISTRY
  22.  
  23. #include <atlbase.h>
  24. //You may derive a class from CComModule and use it if you want to override
  25. //something, but do not change the name of _Module
  26. extern CComModule _Module;
  27. #include <atlcom.h>
  28. #include <atlctl.h>
  29. #include <statreg.h>
  30. #include <statreg.cpp>
  31. #include <atlimpl.cpp>
  32.  
  33. #define FIX_LOCK_NAME
  34. $$IF(SUPPORT_DS_IMEDPARAM || SUPPORT_DS_DMP)
  35. #include "param.h"        // (param.h must come before uuids to avoid redefinitions)
  36. $$ENDIF
  37. #include <dmo.h>
  38. #include <dmoimpl.h>
  39.  
  40. #include "$$CLASS_NAME$$.h"
  41. #include "$$CLASS_NAME$$Prop.h"
  42.  
  43. /////////////////////////////////////////////////////////////////////////////
  44. // $$CLASS_NAME$$Prop
  45.  
  46. $$CLASS_NAME$$Prop::$$CLASS_NAME$$Prop() 
  47. {
  48.     m_dwTitleID = IDS_TITLE_$$DSDMO_DEFINE$$PROP;            // TODO: Define this in the resource file
  49.     m_dwHelpFileID = IDS_HELPFILE_$$DSDMO_DEFINE$$PROP;        // TODO: Define this in the resource file
  50.     m_dwDocStringID = IDS_DOCSTRING_$$DSDMO_DEFINE$$PROP;    // TODO: Define this in the resource file
  51.     m_p$$INTERFACE_NAME$$ = NULL;
  52. }
  53.  
  54. STDMETHODIMP $$CLASS_NAME$$Prop::SetObjects(ULONG cObjects,IUnknown **ppUnk)
  55. {
  56.     if (cObjects != 1)
  57.     {
  58.         return E_UNEXPECTED;
  59.     }
  60.  
  61.     Lock();
  62.  
  63.     HRESULT hr = ppUnk[0]->QueryInterface(IID_$$INTERFACE_NAME$$,(void **) &m_p$$INTERFACE_NAME$$);
  64.  
  65.     Unlock();
  66.  
  67.     return hr;
  68. }
  69.  
  70.  
  71. LRESULT $$CLASS_NAME$$Prop::OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
  72. {
  73.     Lock();
  74.  
  75.     if(m_p$$INTERFACE_NAME$$)
  76.     {
  77.         $$DSDMOID_NAME$$Params params;
  78.         ZeroMemory(¶ms, sizeof($$DSDMOID_NAME$$Params));
  79.         m_p$$INTERFACE_NAME$$->GetAllParameters(¶ms);
  80.  
  81. $$IF(EMPTY_DSDMO)
  82.     // TODO: Initialize controls and their values.
  83.         // Example:
  84.         m_ctValue1.Init(GetDlgItem(IDC_SLIDER1),GetDlgItem(IDC_SLIDER1_DISPLAY),0,100,false);
  85.         m_ctValue1.SetValue(static_cast<float>(params.dwParam1));
  86.         // End of Example
  87. $$ELSE // Sample DMO
  88.         m_ctValue1.Init(GetDlgItem(IDC_SLIDER1),GetDlgItem(IDC_SLIDER1_DISPLAY),(float)0.1,20,false);
  89.         m_ctValue1.SetValue(static_cast<float>(params.fFreq));
  90.  
  91.         m_ctValue2.Init(GetDlgItem(IDC_SLIDER2),GetDlgItem(IDC_SLIDER2_DISPLAY),0,1,false);
  92.         m_ctValue2.SetValue(static_cast<float>(params.fWidth));
  93. $$ENDIF
  94.  
  95.     }
  96.  
  97.     Unlock();
  98.  
  99.     return 1;
  100. }
  101.  
  102.  
  103. STDMETHODIMP $$CLASS_NAME$$Prop::Apply(void)
  104. {
  105.     Lock();
  106.  
  107.     if (!m_p$$INTERFACE_NAME$$)
  108.     {
  109.         Unlock();
  110.         return E_UNEXPECTED;
  111.     }
  112.  
  113.     $$DSDMOID_NAME$$Params params;
  114.     ZeroMemory(¶ms, sizeof($$DSDMOID_NAME$$Params));
  115.  
  116. $$IF(EMPTY_DSDMO)
  117. // TODO: Get parameter values from the controls
  118.     // Example:
  119.     params.dwParam1 = static_cast<DWORD>(m_ctValue1.GetValue());
  120.     // End of Example
  121. $$ELSE // Sample DMO
  122.     params.fFreq = static_cast<float>(m_ctValue1.GetValue());
  123.     params.fWidth = static_cast<float>(m_ctValue2.GetValue());
  124. $$ENDIF
  125.  
  126.     HRESULT hr = m_p$$INTERFACE_NAME$$->SetAllParameters(¶ms);
  127.  
  128.     if (FAILED(hr))
  129.     {
  130.         Unlock();
  131.         return hr;
  132.     }
  133.  
  134.     m_bDirty = FALSE;
  135.  
  136.     Unlock();        
  137.     return S_OK;
  138. }
  139.  
  140.  
  141. LRESULT $$CLASS_NAME$$Prop::OnCommand(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
  142. {
  143.     Lock();
  144.  
  145.     LRESULT lr = m_ctValue1.MessageHandler(uMsg, wParam,lParam, bHandled);
  146. $$IF(!EMPTY_DSDMO) // Sample DMO
  147.     if(!bHandled)
  148.         lr = m_ctValue2.MessageHandler(uMsg, wParam,lParam, bHandled);
  149. $$ENDIF
  150.     if (bHandled)
  151.         SetDirty(true);
  152.  
  153.     Unlock();
  154.  
  155.     return lr;
  156. }
  157.  
  158. LRESULT $$CLASS_NAME$$Prop::OnControlMessage(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
  159. {
  160.     Lock();
  161.     
  162.     LRESULT lr = m_ctValue1.MessageHandler(uMsg, wParam,lParam, bHandled);
  163. $$IF(!EMPTY_DSDMO) // Sample DMO
  164.     if(!bHandled)
  165.         lr = m_ctValue2.MessageHandler(uMsg, wParam,lParam, bHandled);
  166. $$ENDIF
  167.     if (bHandled)
  168.         SetDirty(true);
  169.  
  170.     Unlock();
  171.  
  172.     return lr;
  173. }
  174.