AudioPlugInPropPage.cpp 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326
  1. // AudioPlugInPropPage.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "resource.h"
  5. #include "AudioPlugInPropPage.h"
  6. #include <MedParam.h>
  7. #include "CakeMedParam.h"
  8. #include "Parameters.h"
  9. /////////////////////////////////////////////////////////////////////////////
  10. // CAudioPlugInPropPage property page
  11. extern HMODULE g_hInst;
  12. SPSEffectContext *g_fucko_ctx;
  13. CAudioPlugInPropPage::CAudioPlugInPropPage( IUnknown* pUnk, HRESULT* phr ) :
  14. CUnknown( "AudioPlugInPropPage", pUnk ),
  15. m_hWnd( NULL ),
  16. m_pMediaParams( NULL ),
  17. m_pUICallback( NULL ),
  18. m_pPageSite( NULL ),
  19. m_bDirty( FALSE )
  20. {
  21. SPS_initcontext(&m_ctx); //FUCKO
  22. g_fucko_ctx=&m_ctx;
  23. }
  24. /////////////////////////////////////////////////////////////////////////////
  25. CUnknown * WINAPI CAudioPlugInPropPage::CreateInstance(LPUNKNOWN lpunk, HRESULT *phr)
  26. {
  27. return new CAudioPlugInPropPage( lpunk, phr );
  28. }
  29. /////////////////////////////////////////////////////////////////////////////
  30. CAudioPlugInPropPage::~CAudioPlugInPropPage()
  31. {
  32. if (m_pMediaParams)
  33. m_pMediaParams->Release();
  34. m_pMediaParams = NULL;
  35. if (m_pUICallback)
  36. m_pUICallback->Release();
  37. m_pUICallback = NULL;
  38. }
  39. /////////////////////////////////////////////////////////////////////////////
  40. // CUnknown
  41. HRESULT CAudioPlugInPropPage::NonDelegatingQueryInterface( REFIID riid, void** ppv )
  42. {
  43. if (IID_IUnknown == riid)
  44. return GetInterface( (IUnknown*)this, ppv );
  45. else if (IID_IPropertyPage == riid)
  46. return GetInterface( (IPropertyPage*)this, ppv );
  47. else
  48. {
  49. *ppv = NULL;
  50. return E_NOINTERFACE;
  51. }
  52. }
  53. ////////////////////////////////////////////////////////////////////////////////
  54. // IPropertyPage
  55. HRESULT CAudioPlugInPropPage::GetPageInfo( LPPROPPAGEINFO pPageInfo )
  56. {
  57. IMalloc* pIMalloc;
  58. if (FAILED( CoGetMalloc( MEMCTX_TASK, &pIMalloc ) ))
  59. return E_FAIL;
  60. pPageInfo->pszTitle = (LPOLESTR)pIMalloc->Alloc( 256 );
  61. pIMalloc->Release();
  62. if (!pPageInfo->pszTitle)
  63. return E_OUTOFMEMORY;
  64. static const char szTitle[] = "AudioPlugIn";
  65. mbstowcs( pPageInfo->pszTitle, szTitle, strlen( szTitle ) );
  66. pPageInfo->size.cx = 100;
  67. pPageInfo->size.cy = 100;
  68. pPageInfo->pszDocString = NULL;
  69. pPageInfo->pszHelpFile = NULL;
  70. pPageInfo->dwHelpContext= 0;
  71. // Create the property page in order to determine its size
  72. HWND const hWnd = ::CreateDialogParam( g_hInst, MAKEINTRESOURCE( IDD_DIALOG1 ), GetDesktopWindow(), (DLGPROC)StaticDialogProc, 0 );
  73. if (hWnd)
  74. {
  75. // Get the dialog size and destroy the window
  76. RECT rc;
  77. GetWindowRect( hWnd, &rc );
  78. pPageInfo->size.cx = rc.right - rc.left;
  79. pPageInfo->size.cy = rc.bottom - rc.top;
  80. DestroyWindow( hWnd );
  81. }
  82. return S_OK;
  83. }
  84. ////////////////////////////////////////////////////////////////////////////////
  85. HRESULT CAudioPlugInPropPage::SetObjects( ULONG cObjects, LPUNKNOWN* ppUnk )
  86. {
  87. // Release old interfaces
  88. if (m_pMediaParams)
  89. m_pMediaParams->Release();
  90. m_pMediaParams = NULL;
  91. if (m_pUICallback)
  92. m_pUICallback->Release();
  93. m_pUICallback = NULL;
  94. // Look for a new IFilter
  95. ULONG cObj = 0;
  96. for (ULONG i = 0; i < cObjects; ++i)
  97. {
  98. if (S_OK == ppUnk[i]->QueryInterface( IID_IMediaParams, (void**)&m_pMediaParams ))
  99. {
  100. ppUnk[i]->QueryInterface( IID_IMediaParamsUICallback, (void**)&m_pUICallback );
  101. break;
  102. }
  103. }
  104. // Update controls if we've got a new object and we're activated
  105. if (m_pMediaParams && ::IsWindow( m_hWnd ))
  106. UpdateControls();
  107. return S_OK;
  108. }
  109. ////////////////////////////////////////////////////////////////////////////////
  110. extern BOOL CALLBACK SPS_configWindowProc(HWND hwndDlg, UINT uMsg, WPARAM wParam,LPARAM lParam);
  111. BOOL CALLBACK CAudioPlugInPropPage::StaticDialogProc( HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
  112. {
  113. #if 0
  114. CAudioPlugInPropPage* pPage;
  115. if (WM_INITDIALOG == uMsg)
  116. {
  117. SetWindowLong( hwnd, DWL_USER, lParam );
  118. pPage = reinterpret_cast<CAudioPlugInPropPage*>(lParam);
  119. if (!pPage)
  120. return TRUE;
  121. }
  122. pPage = reinterpret_cast<CAudioPlugInPropPage*>(GetWindowLong( hwnd, DWL_USER ));
  123. if (!pPage)
  124. return TRUE;
  125. return pPage->DialogProc( hwnd, uMsg, wParam, lParam );
  126. #endif
  127. return SPS_configWindowProc(hwnd, uMsg, wParam,lParam);
  128. }
  129. ////////////////////////////////////////////////////////////////////////////////
  130. BOOL CAudioPlugInPropPage::DialogProc( HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
  131. {
  132. //return SPS_configWindowProc(hwnd, uMsg, wParam,lParam);
  133. return 0;
  134. /* switch( uMsg )
  135. {
  136. case WM_INITDIALOG:
  137. m_hWnd = hwnd;
  138. break;
  139. default:
  140. return FALSE;
  141. }
  142. return TRUE;*/
  143. }
  144. ////////////////////////////////////////////////////////////////////////////////
  145. void CAudioPlugInPropPage::UpdateControls()
  146. {
  147. // TODO: update all UI elements to reflect new control state
  148. }
  149. ////////////////////////////////////////////////////////////////////////////////
  150. HRESULT CAudioPlugInPropPage::Activate( HWND hwndParent, LPCRECT pRect, BOOL fModal )
  151. {
  152. if (!pRect)
  153. return E_POINTER;
  154. if (NULL != m_hWnd)
  155. return E_UNEXPECTED; // already active!
  156. m_hWnd = CreateDialogParam( g_hInst, MAKEINTRESOURCE( IDD_DIALOG1 ), hwndParent, (DLGPROC)StaticDialogProc, (LPARAM)&m_ctx );
  157. if (!m_hWnd)
  158. return E_OUTOFMEMORY;
  159. // Refresh the property page controls
  160. UpdateControls();
  161. // Move page into position and show it
  162. Move( pRect );
  163. Show( SW_SHOWNORMAL );
  164. return S_OK;
  165. }
  166. ////////////////////////////////////////////////////////////////////////////////
  167. HRESULT CAudioPlugInPropPage::Move( LPCRECT pRect )
  168. {
  169. if (!pRect)
  170. return E_POINTER;
  171. if (NULL == m_hWnd)
  172. E_UNEXPECTED;
  173. MoveWindow( m_hWnd, pRect->left, pRect->top, pRect->right - pRect->left, pRect->bottom - pRect->top, TRUE );
  174. return S_OK;
  175. }
  176. ////////////////////////////////////////////////////////////////////////////////
  177. HRESULT CAudioPlugInPropPage::Show( UINT nCmdShow )
  178. {
  179. if (NULL == m_hWnd)
  180. E_UNEXPECTED;
  181. // Ignore wrong show flags
  182. if (nCmdShow != SW_SHOW && nCmdShow != SW_SHOWNORMAL && nCmdShow != SW_HIDE)
  183. return E_INVALIDARG;
  184. ShowWindow( m_hWnd, nCmdShow );
  185. if (SW_SHOWNORMAL == nCmdShow || SW_SHOW == nCmdShow)
  186. {
  187. // TODO: set the focus to which control needs it
  188. }
  189. return S_OK;
  190. }
  191. ////////////////////////////////////////////////////////////////////////////////
  192. HRESULT CAudioPlugInPropPage::Deactivate()
  193. {
  194. if (NULL == m_hWnd)
  195. return E_UNEXPECTED;
  196. DestroyWindow( m_hWnd );
  197. m_hWnd = NULL;
  198. return S_OK;
  199. }
  200. ////////////////////////////////////////////////////////////////////////////////
  201. HRESULT CAudioPlugInPropPage::SetPageSite( LPPROPERTYPAGESITE pPageSite )
  202. {
  203. if (pPageSite)
  204. {
  205. if (m_pPageSite)
  206. return E_UNEXPECTED;
  207. m_pPageSite = pPageSite;
  208. m_pPageSite->AddRef();
  209. }
  210. else
  211. {
  212. if (m_pPageSite == NULL)
  213. return E_UNEXPECTED;
  214. m_pPageSite->Release();
  215. m_pPageSite = NULL;
  216. }
  217. return S_OK;
  218. }
  219. ////////////////////////////////////////////////////////////////////////////////
  220. HRESULT CAudioPlugInPropPage::Apply()
  221. {
  222. // Take no action except clearing the dirty flag.
  223. // So that the property page may be used in realtime, all user interface
  224. // changes are immediately passed to the filter. I.e. there is no Cancel.
  225. m_bDirty = FALSE;
  226. return S_OK;
  227. }
  228. ////////////////////////////////////////////////////////////////////////////////
  229. HRESULT CAudioPlugInPropPage::IsPageDirty( void )
  230. {
  231. return m_bDirty ? S_OK : S_FALSE;
  232. }
  233. /////////////////////////////////////////////////////////////////////////////
  234. HRESULT CAudioPlugInPropPage::Help( LPCWSTR lpszHelpDir )
  235. {
  236. // Get location of DLL
  237. char szDLL[ _MAX_PATH ];
  238. if (0 == ::GetModuleFileName( g_hInst, szDLL, sizeof szDLL ))
  239. return E_FAIL;
  240. // Convert to location of .HLP file
  241. char szHelp[ _MAX_PATH ];
  242. ::strncpy( szHelp, szDLL, ::strlen( szDLL ) - 3 );
  243. ::strcat( szHelp, "HLP" );
  244. // Call help
  245. if (::WinHelp( m_hWnd, szHelp, HELP_CONTENTS, NULL ))
  246. return S_OK;
  247. return E_FAIL;
  248. }
  249. /////////////////////////////////////////////////////////////////////////////
  250. HRESULT CAudioPlugInPropPage::TranslateAccelerator( LPMSG lpMsg )
  251. {
  252. return E_NOTIMPL;
  253. }
  254. /////////////////////////////////////////////////////////////////////////////