Leaked source code of windows server 2003
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.

251 lines
8.4 KiB

  1. /****************************************************************************
  2. * @doc INTERNAL VDEVICEP
  3. *
  4. * @module VDeviceP.cpp | Source file for the <c CVDeviceProperties>
  5. * class used to implement a property page to test the <i ITVfwCaptureDialogs>,
  6. * as well as <i ITAddress> and <ITStream> interfaces to select video
  7. * capture devices.
  8. ***************************************************************************/
  9. #include "Precomp.h"
  10. extern HINSTANCE ghInst;
  11. /****************************************************************************
  12. * @doc INTERNAL CVDEVICEPMETHOD
  13. *
  14. * @mfunc HPROPSHEETPAGE | CVDeviceProperties | OnCreate | This
  15. * method creates a new page for a property sheet.
  16. *
  17. * @rdesc Returns the handle to the new property sheet if successful, or
  18. * NULL otherwise.
  19. ***************************************************************************/
  20. HPROPSHEETPAGE CVDeviceProperties::OnCreate()
  21. {
  22. PROPSHEETPAGE psp;
  23. psp.dwSize = sizeof(psp);
  24. psp.dwFlags = PSP_USEREFPARENT;
  25. psp.hInstance = ghInst;
  26. psp.pszTemplate = MAKEINTRESOURCE(IDD_CaptureDeviceProperties);
  27. psp.pfnDlgProc = BaseDlgProc;
  28. psp.pcRefParent = 0;
  29. psp.pfnCallback = (LPFNPSPCALLBACK)NULL;
  30. psp.lParam = (LPARAM)this;
  31. return CreatePropertySheetPage(&psp);
  32. }
  33. /****************************************************************************
  34. * @doc INTERNAL CVDEVICEPMETHOD
  35. *
  36. * @mfunc void | CVDeviceProperties | CVDeviceProperties | This
  37. * method is the constructor for the property page object. It simply
  38. * calls the constructor of the property page base class.
  39. *
  40. * @rdesc Nada.
  41. ***************************************************************************/
  42. CVDeviceProperties::CVDeviceProperties()
  43. {
  44. FX_ENTRY("CVDeviceProperties::CVDeviceProperties")
  45. DbgLog((LOG_TRACE, DBG_LEVEL_TRACE_DETAILS, TEXT("%s: begin"), _fx_));
  46. #if USE_VFW
  47. m_pITVfwCaptureDialogs = NULL;
  48. #endif
  49. DbgLog((LOG_TRACE, DBG_LEVEL_TRACE_DETAILS, TEXT("%s: end"), _fx_));
  50. }
  51. /****************************************************************************
  52. * @doc INTERNAL CVDEVICEPMETHOD
  53. *
  54. * @mfunc void | CVDeviceProperties | ~CVDeviceProperties | This
  55. * method is the destructor for capture device property page. It
  56. * simply calls the base class destructor.
  57. *
  58. * @rdesc Nada.
  59. ***************************************************************************/
  60. CVDeviceProperties::~CVDeviceProperties()
  61. {
  62. FX_ENTRY("CVDeviceProperties::~CVDeviceProperties")
  63. DbgLog((LOG_TRACE, DBG_LEVEL_TRACE_DETAILS, TEXT("%s: begin"), _fx_));
  64. DbgLog((LOG_TRACE, DBG_LEVEL_TRACE_DETAILS, TEXT("%s: end"), _fx_));
  65. }
  66. /****************************************************************************
  67. * @doc INTERNAL CVDEVICEPMETHOD
  68. *
  69. * @mfunc HRESULT | CVDeviceProperties | OnConnect | This
  70. * method is called when the property page is connected to a TAPI object.
  71. *
  72. * @parm ITTerminal* | pITTerminal | Specifies a pointer to the <i ITTerminal>
  73. * interface used to identify the capture device.
  74. *
  75. * @rdesc This method returns an HRESULT value that depends on the
  76. * implementation of the interface. HRESULT can include one of the
  77. * following standard constants, or other values not listed:
  78. *
  79. * @flag E_FAIL | Failure
  80. * @flag E_POINTER | Null pointer argument
  81. * @flag E_NOTIMPL | Method is not supported
  82. * @flag NOERROR | No error
  83. ***************************************************************************/
  84. HRESULT CVDeviceProperties::OnConnect(ITTerminal *pITTerminal)
  85. {
  86. HRESULT Hr = NOERROR;
  87. FX_ENTRY("CVDeviceProperties::OnConnect")
  88. DbgLog((LOG_TRACE, DBG_LEVEL_TRACE_DETAILS, TEXT("%s: begin"), _fx_));
  89. // Validate input parameters
  90. if (!pITTerminal)
  91. {
  92. DbgLog((LOG_ERROR, DBG_LEVEL_TRACE_FAILURES, TEXT("%s: ERROR: invalid input parameter"), _fx_));
  93. Hr = E_POINTER;
  94. goto MyExit;
  95. }
  96. #if USE_VFW
  97. // Get the video VfW capture device interface
  98. if (SUCCEEDED (Hr = pITTerminal->QueryInterface(&m_pITVfwCaptureDialogs)))
  99. {
  100. DbgLog((LOG_TRACE, DBG_LEVEL_TRACE_DETAILS, TEXT("%s: SUCCESS: m_pITVfwCaptureDialogs=0x%08lX"), _fx_, m_pITVfwCaptureDialogs));
  101. }
  102. else
  103. {
  104. m_pITVfwCaptureDialogs = NULL;
  105. DbgLog((LOG_ERROR, DBG_LEVEL_TRACE_FAILURES, TEXT("%s: ERROR: IOCTL failed Hr=0x%08lX"), _fx_, Hr));
  106. }
  107. #endif
  108. MyExit:
  109. DbgLog((LOG_TRACE, DBG_LEVEL_TRACE_DETAILS, TEXT("%s: end"), _fx_));
  110. return Hr;
  111. }
  112. /****************************************************************************
  113. * @doc INTERNAL CVDEVICEPMETHOD
  114. *
  115. * @mfunc HRESULT | CVDeviceProperties | OnDisconnect | This
  116. * method is called when the property page is disconnected from the owning
  117. * filter.
  118. *
  119. * @rdesc This method returns an HRESULT value that depends on the
  120. * implementation of the interface. HRESULT can include one of the
  121. * following standard constants, or other values not listed:
  122. *
  123. * @flag NOERROR | No error
  124. ***************************************************************************/
  125. HRESULT CVDeviceProperties::OnDisconnect()
  126. {
  127. FX_ENTRY("CVDeviceProperties::OnDisconnect")
  128. DbgLog((LOG_TRACE, DBG_LEVEL_TRACE_DETAILS, TEXT("%s: begin"), _fx_));
  129. #if USE_VFW
  130. // Make sure the interface pointer is still valid
  131. if (!m_pITVfwCaptureDialogs)
  132. {
  133. DbgLog((LOG_ERROR, DBG_LEVEL_TRACE_FAILURES, TEXT("%s: WARNING: already disconnected!"), _fx_));
  134. }
  135. else
  136. {
  137. // Release the interface
  138. m_pITVfwCaptureDialogs->Release();
  139. m_pITVfwCaptureDialogs = NULL;
  140. DbgLog((LOG_TRACE, DBG_LEVEL_TRACE_DETAILS, TEXT("%s: SUCCESS: releasing m_pITVfwCaptureDialogs"), _fx_));
  141. }
  142. #endif
  143. DbgLog((LOG_TRACE, DBG_LEVEL_TRACE_DETAILS, TEXT("%s: end"), _fx_));
  144. return NOERROR;
  145. }
  146. /****************************************************************************
  147. * @doc INTERNAL CVDEVICEPMETHOD
  148. *
  149. * @mfunc BOOL | CVDeviceProperties | BaseDlgProc | This
  150. * method is called when a message is sent to the property page dialog box.
  151. *
  152. * @rdesc By default, returns the value returned by the Win32 DefWindowProc function.
  153. ***************************************************************************/
  154. INT_PTR CALLBACK CVDeviceProperties::BaseDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
  155. {
  156. CVDeviceProperties *pSV = (CVDeviceProperties*)GetWindowLong(hDlg, DWL_USER);
  157. int iNotify = HIWORD (wParam);
  158. int j;
  159. switch (uMsg)
  160. {
  161. case WM_INITDIALOG:
  162. {
  163. LPPROPSHEETPAGE psp = (LPPROPSHEETPAGE)lParam;
  164. pSV = (CVDeviceProperties*)psp->lParam;
  165. pSV->m_hDlg = hDlg;
  166. SetWindowLong(hDlg, DWL_USER, (LPARAM)pSV);
  167. pSV->m_bInit = FALSE;
  168. #if USE_VFW
  169. EnableWindow(GetDlgItem(hDlg, IDC_Device_SourceDlg), (BOOL)(pSV->m_pITVfwCaptureDialogs && pSV->m_pITVfwCaptureDialogs->HasDialog(VfwCaptureDialog_Source) == S_OK));
  170. EnableWindow(GetDlgItem(hDlg, IDC_Device_FormatDlg), (BOOL)(pSV->m_pITVfwCaptureDialogs && pSV->m_pITVfwCaptureDialogs->HasDialog(VfwCaptureDialog_Format) == S_OK));
  171. EnableWindow(GetDlgItem(hDlg, IDC_Device_DisplayDlg), (BOOL)(pSV->m_pITVfwCaptureDialogs && pSV->m_pITVfwCaptureDialogs->HasDialog(VfwCaptureDialog_Display) == S_OK));
  172. #endif
  173. // Put some code here to enumerate the terminals and populate the dialog box
  174. EnableWindow(GetDlgItem(hDlg, IDC_Device_Selection), FALSE);
  175. EnableWindow(GetDlgItem(hDlg, IDC_CONTROL_DEFAULT), FALSE);
  176. pSV->m_bInit = TRUE;
  177. return TRUE;
  178. }
  179. break;
  180. case WM_COMMAND:
  181. if (pSV && pSV->m_bInit)
  182. {
  183. switch (LOWORD(wParam))
  184. {
  185. #if USE_VFW
  186. case IDC_Device_SourceDlg:
  187. if (pSV->m_pITVfwCaptureDialogs)
  188. pSV->m_pITVfwCaptureDialogs->ShowDialog(VfwCaptureDialog_Source, hDlg);
  189. break;
  190. case IDC_Device_FormatDlg:
  191. if (pSV->m_pITVfwCaptureDialogs)
  192. pSV->m_pITVfwCaptureDialogs->ShowDialog(VfwCaptureDialog_Format, hDlg);
  193. break;
  194. case IDC_Device_DisplayDlg:
  195. if (pSV->m_pITVfwCaptureDialogs)
  196. pSV->m_pITVfwCaptureDialogs->ShowDialog(VfwCaptureDialog_Display, hDlg);
  197. break;
  198. #endif
  199. case IDC_Device_Selection:
  200. if (HIWORD(wParam) == CBN_SELCHANGE)
  201. {
  202. // Put some code to select a new terminal on the stream
  203. PropSheet_Changed(GetParent(hDlg), hDlg);
  204. }
  205. break;
  206. default:
  207. break;
  208. }
  209. }
  210. default:
  211. return FALSE;
  212. }
  213. return TRUE;
  214. }