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.

293 lines
7.6 KiB

  1. // Copyright (c) 1999 Microsoft Corporation. All Rights Reserved.
  2. // dvdopt.cpp : Implementation of Cdvdopt
  3. #include "stdafx.h"
  4. #include "Msdvdopt.h"
  5. #include "dvdopt.h"
  6. #include "COptDlg.h"
  7. #include "override.h"
  8. extern LPTSTR LoadStringFromRes(DWORD redId);
  9. /////////////////////////////////////////////////////////////////////////////
  10. // Cdvdopt
  11. /*************************************************************/
  12. /* Name: Cdvdopt
  13. /* Description: Constructor
  14. /*************************************************************/
  15. Cdvdopt::Cdvdopt()
  16. {
  17. m_pDlgOpt = NULL;
  18. m_pDvd = NULL;
  19. m_hParentWnd = NULL;
  20. }
  21. /*************************************************************/
  22. /* Name: ~Cdvdopt
  23. /* Description: destructor
  24. /*************************************************************/
  25. Cdvdopt::~Cdvdopt(){
  26. ATLTRACE(TEXT("In the destructor of the CDVDOPT !\n"));
  27. CleanUp();
  28. #ifdef _DEBUG
  29. m_pDvd.Release();
  30. #endif
  31. }/* end of function Cdvdopt */
  32. /*************************************************************/
  33. /* Name: CleanUp
  34. /* Description: Delete all dialogs
  35. /*************************************************************/
  36. void Cdvdopt::CleanUp()
  37. {
  38. if (m_pDlgOpt) {
  39. delete m_pDlgOpt;
  40. m_pDlgOpt = NULL;
  41. }
  42. }
  43. /*************************************************************/
  44. /* Name: get_WebDVD
  45. /* Description: Get IDispatch of the IMSWebDVD that the options
  46. /* dialog is controling
  47. /*************************************************************/
  48. STDMETHODIMP Cdvdopt::get_WebDVD(IDispatch **pVal){
  49. HRESULT hr = E_FAIL;
  50. if(!m_pDvd){
  51. return(hr);
  52. }/* end of if statement */
  53. hr = m_pDvd->QueryInterface(IID_IDispatch, (LPVOID*) pVal);
  54. return hr;
  55. }
  56. /*************************************************************/
  57. /* Name: put_WebDVD
  58. /* Description: Set IDispatch of a IMSWebDVD that the options
  59. /* dialog is going to control
  60. /*************************************************************/
  61. STDMETHODIMP Cdvdopt::put_WebDVD(IDispatch *newVal){
  62. HRESULT hr = newVal->QueryInterface(IID_IMSWebDVD, (LPVOID*) &m_pDvd);
  63. #ifdef _DEBUG2
  64. IFilterGraph* pGraph = NULL;
  65. hr = pDvd->QueryInterface(IID_IFilterGraph, (LPVOID*) &pGraph);
  66. ATLASSERT(SUCCEEDED(hr));
  67. if (SUCCEEDED(hr))
  68. pGraph->Release();
  69. #endif
  70. CleanUp();
  71. m_pDlgOpt = new COptionsDlg(m_pDvd);
  72. m_pDlgOpt->SetDvdOpt(this);
  73. return S_OK;
  74. }
  75. /*************************************************************/
  76. /* Name: get_ParentWindow
  77. /* Description: Get parent window of the options dialog
  78. /*************************************************************/
  79. STDMETHODIMP Cdvdopt::get_ParentWindow(VARIANT *pVal)
  80. {
  81. if (NULL == pVal)
  82. return E_POINTER;
  83. /*
  84. * BUGBUG: If pVal was a properly initialized variant, we should
  85. * call VariantClear to free any pointers. If it wasn't initialized
  86. * VariantInit is the right thing to call instead. I prefer a leak
  87. * to a crash so I'll use VariantInit below
  88. */
  89. VariantInit(pVal);
  90. #ifdef _WIN64
  91. pVal->vt = VT_I8;
  92. pVal->llVal = (LONG_PTR)m_hParentWnd;
  93. #else
  94. pVal->vt = VT_I4;
  95. pVal->lVal = (LONG_PTR)m_hParentWnd;
  96. #endif
  97. return S_OK;
  98. }
  99. /*************************************************************/
  100. /* Name: put_ParentWindow
  101. /* Description: Set parent window of the options dialog
  102. /*************************************************************/
  103. STDMETHODIMP Cdvdopt::put_ParentWindow(VARIANT newVal)
  104. {
  105. VARIANT dest;
  106. VariantInit(&dest);
  107. HRESULT hr = S_OK;
  108. #ifdef _WIN64
  109. hr = VariantChangeTypeEx(&dest, &newVal, 0, 0, VT_I8);
  110. if (FAILED(hr))
  111. return hr;
  112. m_hParentWnd = (HWND) dest.llVal;
  113. #else
  114. hr = VariantChangeTypeEx(&dest, &newVal, 0, 0, VT_I4);
  115. if (FAILED(hr))
  116. return hr;
  117. m_hParentWnd = (HWND) dest.lVal;
  118. #endif
  119. return hr;
  120. }
  121. /*************************************************************/
  122. /* Name: Show
  123. /* Description: Show the options dialog
  124. /*************************************************************/
  125. STDMETHODIMP Cdvdopt::Show()
  126. {
  127. m_pDlgOpt->DoModal(m_hParentWnd);
  128. return S_OK;
  129. }
  130. /*************************************************************/
  131. /* Name: Close
  132. /* Description: Close the options dialog
  133. /*************************************************************/
  134. STDMETHODIMP Cdvdopt::Close()
  135. {
  136. m_pDlgOpt->EndDialog(0);
  137. return S_OK;
  138. }
  139. /*************************************************************/
  140. /* Name: Power
  141. /* Description: Raise a number to a power
  142. /*************************************************************/
  143. double Power(LONG n, LONG p)
  144. {
  145. double result = 1;
  146. if (p==0) return result;
  147. if (p>0) {
  148. while (p--)
  149. result *= n;
  150. return result;
  151. }
  152. else {
  153. while (p++)
  154. result *= n;
  155. return 1/result;
  156. }
  157. }
  158. /*************************************************************/
  159. /* Name: get_ForwardScanSpeed
  160. /* Description: return the forward scan speed
  161. /*************************************************************/
  162. STDMETHODIMP Cdvdopt::get_ForwardScanSpeed(double *pVal)
  163. {
  164. *pVal = m_pDlgOpt->m_dFFSpeed;
  165. return S_OK;
  166. }
  167. /*************************************************************/
  168. /* Name: put_ForwardScanSpeed
  169. /* Description: return the forward scan speed
  170. /*************************************************************/
  171. STDMETHODIMP Cdvdopt::put_ForwardScanSpeed(double newVal)
  172. {
  173. m_pDlgOpt->m_dFFSpeed = newVal;
  174. return S_OK;
  175. }
  176. /*************************************************************/
  177. /* Name: get_BackwardScanSpeed
  178. /* Description: return backward scan speed
  179. /*************************************************************/
  180. STDMETHODIMP Cdvdopt::get_BackwardScanSpeed(double *pVal)
  181. {
  182. *pVal = m_pDlgOpt->m_dBWSpeed;
  183. return S_OK;
  184. }
  185. /*************************************************************/
  186. /* Name: put_BackwardScanSpeed
  187. /* Description: return play speed
  188. /*************************************************************/
  189. STDMETHODIMP Cdvdopt::put_BackwardScanSpeed(double newVal)
  190. {
  191. m_pDlgOpt->m_dBWSpeed = newVal;
  192. return S_OK;
  193. }
  194. /*************************************************************/
  195. /* Name: get_PlaySpeed
  196. /* Description: return play speed
  197. /*************************************************************/
  198. STDMETHODIMP Cdvdopt::get_PlaySpeed(double *pVal)
  199. {
  200. *pVal = m_pDlgOpt->m_dPlaySpeed;
  201. return S_OK;
  202. }
  203. /*************************************************************/
  204. /* Name: put_PlaySpeed
  205. /* Description: return play speed
  206. /*************************************************************/
  207. STDMETHODIMP Cdvdopt::put_PlaySpeed(double newVal)
  208. {
  209. m_pDlgOpt->m_dPlaySpeed = newVal;
  210. return S_OK;
  211. }
  212. /*************************************************************/
  213. /* Name: ParentalLevelOverride
  214. /* Description:
  215. /*************************************************************/
  216. STDMETHODIMP Cdvdopt::ParentalLevelOverride(PG_OVERRIDE_REASON reason)
  217. {
  218. COverrideDlg dlg(m_pDvd);
  219. dlg.SetReason(reason);
  220. dlg.DoModal();
  221. return S_OK;
  222. }
  223. int DVDMessageBox(HWND hWnd, LPCTSTR lpszText, LPCTSTR lpszCaption, UINT nType)
  224. {
  225. LPTSTR csCaption;
  226. if(lpszCaption == NULL)
  227. {
  228. csCaption = LoadStringFromRes(IDS_MSGBOX_TITLE);
  229. MessageBox(hWnd, lpszText, csCaption, nType );
  230. delete[] csCaption;
  231. return 0;
  232. }
  233. else
  234. return MessageBox(hWnd, lpszText, lpszCaption, nType );
  235. }
  236. int DVDMessageBox(HWND hWnd, UINT nID, LPCTSTR lpszCaption, UINT nType)
  237. {
  238. LPTSTR csMsgString, csCaption;
  239. csMsgString = LoadStringFromRes(nID);
  240. if(lpszCaption == NULL)
  241. {
  242. csCaption = LoadStringFromRes(IDS_MSGBOX_TITLE);
  243. MessageBox(hWnd, csMsgString, csCaption, nType );
  244. delete[] csCaption;
  245. }
  246. else {
  247. MessageBox(hWnd, csMsgString, lpszCaption, nType );
  248. }
  249. delete[] csMsgString;
  250. return 0;
  251. }