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.

199 lines
6.3 KiB

  1. // Copyright (c) 1996 - 1998 Microsoft Corporation. All Rights Reserved.
  2. #include <streams.h>
  3. #include <mmreg.h>
  4. #include <commctrl.h>
  5. #include "project.h"
  6. #include "mpgcodec.h"
  7. #include <olectl.h>
  8. #include <stdio.h>
  9. extern HINSTANCE hInst;
  10. // these lines copied from SDK\CLASSES\BASE\FILTER.H
  11. #define QueryFilterInfoReleaseGraph(fi) if ((fi).pGraph) (fi).pGraph->Release();
  12. typedef HRESULT (STDAPICALLTYPE *LPOCPF)(HWND hwndOwner, UINT x, UINT y,
  13. LPCOLESTR lpszCaption, ULONG cObjects, LPUNKNOWN FAR* ppUnk, ULONG cPages,
  14. LPCLSID pPageClsID, LCID lcid, DWORD dwReserved, LPVOID pvReserved);
  15. typedef HRESULT (STDAPICALLTYPE *LPOI)(LPVOID pvReserved);
  16. typedef void (STDAPICALLTYPE *LPOUI)(void);
  17. //
  18. // Release the reference count for those filters put into the configuration
  19. // listbox
  20. //
  21. void ReleaseFilters(HWND hwndListbox)
  22. {
  23. if (hwndListbox) {
  24. IBaseFilter* pFilter;
  25. for (int i=ListBox_GetCount(hwndListbox); i--;) {
  26. if (pFilter = (IBaseFilter*)ListBox_GetItemData(hwndListbox, i))
  27. pFilter->Release();
  28. else
  29. break;
  30. }
  31. }
  32. }
  33. INT_PTR CALLBACK ConfigDlgProc(HWND hDlg, UINT wMsg, WPARAM wParam, LPARAM lParam)
  34. {
  35. switch (wMsg) {
  36. case WM_INITDIALOG:
  37. {
  38. IFilterGraph *pFG = (IFilterGraph *) lParam;
  39. IEnumFilters* pEF;
  40. IBaseFilter* pFilter;
  41. FILTER_INFO Info;
  42. HWND hlist = GetDlgItem(hDlg, IDC_FILTERS);
  43. if (pFG == NULL)
  44. return FALSE;
  45. // Grab an enumerator for the filter graph.
  46. HRESULT hr = pFG->EnumFilters(&pEF);
  47. // ASSERT(SUCCEEDED(hr));
  48. // Check out each filter.
  49. while (pEF->Next(1, &pFilter, NULL) == S_OK)
  50. {
  51. int Index;
  52. hr = pFilter->QueryFilterInfo(&Info);
  53. // ASSERT(SUCCEEDED(hr));
  54. QueryFilterInfoReleaseGraph(Info);
  55. #ifdef UNICODE
  56. Index = ListBox_AddString(hlist, Info.achName);
  57. #else
  58. CHAR aFilterName[MAX_FILTER_NAME];
  59. WideCharToMultiByte(CP_ACP, 0, Info.achName, -1, aFilterName, MAX_FILTER_NAME, NULL, NULL);
  60. Index = ListBox_AddString(hlist, aFilterName);
  61. #endif
  62. // ASSERT(Index != LB_ERR);
  63. // ASSERT(Index != LB_ERRSPACE);
  64. // Store the IBaseFilter pointer with the listbox item.
  65. // it gets used if the properties have to be queried
  66. ListBox_SetItemData(hlist, Index, pFilter);
  67. }
  68. pEF->Release();
  69. }
  70. return TRUE;
  71. case WM_ENDSESSION:
  72. if (wParam) {
  73. ReleaseFilters(GetDlgItem(hDlg, IDC_FILTERS));
  74. EndDialog(hDlg, FALSE);
  75. }
  76. break;
  77. case WM_COMMAND:
  78. switch (LOWORD(wParam)) {
  79. case IDOK:
  80. ReleaseFilters(GetDlgItem(hDlg, IDC_FILTERS));
  81. EndDialog(hDlg, TRUE);
  82. break;
  83. case IDCANCEL:
  84. ReleaseFilters(GetDlgItem(hDlg, IDC_FILTERS));
  85. EndDialog(hDlg, FALSE);
  86. break;
  87. case IDC_FILTERS:
  88. if (HIWORD(wParam) == LBN_SELCHANGE) {
  89. HRESULT hr = E_FAIL;
  90. HWND hlist = GetDlgItem(hDlg, IDC_FILTERS);
  91. IBaseFilter *pF;
  92. ISpecifyPropertyPages *pSPP;
  93. pF = (IBaseFilter *)
  94. ListBox_GetItemData(hlist, ListBox_GetCurSel(hlist));
  95. if (pF) {
  96. hr = pF->QueryInterface(IID_ISpecifyPropertyPages,
  97. (void **)&pSPP);
  98. }
  99. if (hr == S_OK) {
  100. pSPP->Release();
  101. }
  102. EnableWindow(GetDlgItem(hDlg, IDC_PROPERTIES), hr == S_OK);
  103. }
  104. else if (HIWORD(wParam) == LBN_DBLCLK) {
  105. HWND hwndBtn = GetDlgItem(hDlg, IDC_PROPERTIES);
  106. SendMessage(hwndBtn, WM_LBUTTONDOWN, 0, 0L);
  107. SendMessage(hwndBtn, WM_LBUTTONUP, 0, 0L);
  108. }
  109. break;
  110. case IDC_PROPERTIES:
  111. {
  112. HWND hlist = GetDlgItem(hDlg, IDC_FILTERS);
  113. IBaseFilter *pF;
  114. pF = (IBaseFilter *)
  115. ListBox_GetItemData(hlist, ListBox_GetCurSel(hlist));
  116. static const TCHAR szOleControlDll[] = TEXT("OLEPRO32.dll");
  117. static const char szOCPF[] = "OleCreatePropertyFrame";
  118. static const TCHAR szOleDll[] = TEXT("OLE32.dll");
  119. static const char szOleInit[] = "OleInitialize";
  120. static const char szOleUninit[] = "OleUninitialize";
  121. HINSTANCE hinst = LoadLibrary(szOleControlDll);
  122. if (!hinst) break;
  123. LPOCPF lpfn = (LPOCPF)GetProcAddress(hinst, szOCPF);
  124. HINSTANCE hinstOLE = LoadLibrary(szOleDll);
  125. if (hinstOLE) {
  126. LPOI lpfnInit = (LPOI)GetProcAddress(hinstOLE, szOleInit);
  127. LPOUI lpfnUninit = (LPOUI)GetProcAddress(hinstOLE, szOleUninit);
  128. if (lpfn && lpfnInit && lpfnUninit) {
  129. (*lpfnInit) (NULL);
  130. (*lpfn)(hDlg, // Parent
  131. 0, // x coordinate
  132. 0, // y coordinate
  133. L"Filter", // Caption
  134. 1, // Number of objects
  135. (IUnknown**)&pF, // 1 object
  136. 0, // No pages :- will use
  137. NULL, // ISpecifyPropertyPages
  138. 0, // AmbientLocaleID(),
  139. 0, // Reserved
  140. NULL); // Reserved
  141. (*lpfnUninit) ();
  142. }
  143. FreeLibrary(hinstOLE);
  144. }
  145. FreeLibrary(hinst);
  146. }
  147. break;
  148. }
  149. break;
  150. }
  151. return FALSE;
  152. }
  153. BOOL CMpegMovie::ConfigDialog(HWND hwnd)
  154. {
  155. BOOL f = TRUE;
  156. f = (BOOL) DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_PROPPAGE),
  157. hwnd, ConfigDlgProc, (DWORD_PTR)m_Fg);
  158. return f;
  159. }