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.

274 lines
9.0 KiB

  1. // Copyright (c) 1999 Microsoft Corporation. All Rights Reserved.
  2. /*************************************************************/
  3. /* Name: sprm_OnInitDialog
  4. /* Description: OnInitDialog for the Viewing Options page
  5. /*************************************************************/
  6. #include "stdafx.h"
  7. #include "COptDlg.h"
  8. // Language ID's supported by DVD Nav
  9. WORD langIDs[] = {
  10. LANG_AFRIKAANS ,
  11. LANG_ALBANIAN ,
  12. LANG_ARABIC ,
  13. LANG_BASQUE ,
  14. LANG_BELARUSIAN ,
  15. LANG_BULGARIAN ,
  16. LANG_CATALAN ,
  17. LANG_CHINESE ,
  18. LANG_CROATIAN ,
  19. LANG_CZECH ,
  20. LANG_DANISH ,
  21. LANG_DUTCH ,
  22. LANG_ENGLISH ,
  23. LANG_ESTONIAN ,
  24. LANG_FAEROESE ,
  25. LANG_FARSI ,
  26. LANG_FINNISH ,
  27. LANG_FRENCH ,
  28. LANG_GERMAN ,
  29. LANG_GREEK ,
  30. LANG_HEBREW ,
  31. LANG_HUNGARIAN ,
  32. LANG_ICELANDIC ,
  33. LANG_INDONESIAN ,
  34. LANG_ITALIAN ,
  35. LANG_JAPANESE ,
  36. LANG_KOREAN ,
  37. LANG_LATVIAN ,
  38. LANG_LITHUANIAN ,
  39. LANG_MALAY ,
  40. LANG_NORWEGIAN ,
  41. LANG_POLISH ,
  42. LANG_PORTUGUESE ,
  43. LANG_ROMANIAN ,
  44. LANG_RUSSIAN ,
  45. LANG_SERBIAN ,
  46. LANG_SLOVAK ,
  47. LANG_SLOVENIAN ,
  48. LANG_SPANISH ,
  49. LANG_SWAHILI ,
  50. LANG_SWEDISH ,
  51. LANG_THAI ,
  52. LANG_TURKISH ,
  53. LANG_UKRAINIAN
  54. };
  55. /*************************************************************/
  56. /* Name: sprm_InitLangList
  57. /* Description: Initial a combo box with available languages
  58. /* highlight the one with LCID equal to id
  59. /*************************************************************/
  60. HRESULT COptionsDlg::sprm_InitLangList(HWND cList, WORD id)
  61. {
  62. USES_CONVERSION;
  63. ::SendMessage(cList, CB_RESETCONTENT, 0, 0);
  64. LPTSTR pszDefault = LoadStringFromRes(IDS_INI_TITLE_DEFAULT);
  65. ::SendMessage(cList, CB_INSERTSTRING, 0, (LPARAM)pszDefault);
  66. ::SendMessage(cList, CB_SETCURSEL, 0, 0);
  67. delete pszDefault;
  68. if (id == LANG_NEUTRAL) {
  69. id = PRIMARYLANGID(::GetUserDefaultLangID());
  70. }
  71. for (int i=0; i<sizeof(langIDs)/sizeof(WORD); i++) {
  72. CComBSTR strLang;
  73. m_pDvd->GetLangFromLangID(long(langIDs[i]), &strLang);
  74. ::SendMessage(cList, CB_INSERTSTRING, (UINT)-1, (LPARAM)OLE2T(strLang));
  75. if (langIDs[i] == id)
  76. // First item in list is "Title Default"
  77. ::SendMessage(cList, CB_SETCURSEL, i+1, 0);
  78. }
  79. return S_OK;
  80. }
  81. /*************************************************************/
  82. /* Name: sprm_OnInitDialog
  83. /* Description:
  84. /*************************************************************/
  85. HRESULT COptionsDlg::sprm_OnInitDialog(HWND hwndDlg)
  86. {
  87. HWND hwndAudList = ::GetDlgItem(hwndDlg, IDC_AUDIO_LANG);
  88. HWND hwndSPList = ::GetDlgItem(hwndDlg, IDC_SUBPIC_LANG);
  89. HWND hwndMenuList = ::GetDlgItem(hwndDlg, IDC_MENU_LANG);
  90. HWND screenSaverCheck = ::GetDlgItem(hwndDlg, IDC_DISABLE_SCREENSAVER);
  91. HWND bookmarkOnStopCheck = ::GetDlgItem(hwndDlg, IDC_BOOKMARK_STOP);
  92. HWND bookmarkOnCloseCheck = ::GetDlgItem(hwndDlg, IDC_BOOKMARK_CLOSE);
  93. if (!hwndAudList || !hwndSPList || !hwndMenuList)
  94. return S_FALSE;
  95. try {
  96. HRESULT hr = S_OK;
  97. CComPtr<IMSDVDAdm> pDvdAdm;
  98. hr = GetDvdAdm((LPVOID*) &pDvdAdm);
  99. if (FAILED(hr) || !pDvdAdm)
  100. throw(hr);
  101. VARIANT_BOOL temp;
  102. LCID audioLCID;
  103. LCID subpictureLCID;
  104. LCID menuLCID;
  105. pDvdAdm->get_DisableScreenSaver(&temp);
  106. BOOL fDisabled = (temp == VARIANT_FALSE? FALSE:TRUE);
  107. ::SendMessage(screenSaverCheck, BM_SETCHECK, fDisabled, 0);
  108. pDvdAdm->get_BookmarkOnStop(&temp);
  109. fDisabled = (temp == VARIANT_FALSE? FALSE:TRUE);
  110. ::SendMessage(bookmarkOnStopCheck, BM_SETCHECK, fDisabled, 0);
  111. pDvdAdm->get_BookmarkOnClose(&temp);
  112. fDisabled = (temp == VARIANT_FALSE? FALSE:TRUE);
  113. ::SendMessage(bookmarkOnCloseCheck, BM_SETCHECK, fDisabled, 0);
  114. pDvdAdm->get_DefaultAudioLCID((long*)&audioLCID);
  115. pDvdAdm->get_DefaultSubpictureLCID((long*)&subpictureLCID);
  116. pDvdAdm->get_DefaultMenuLCID((long*)&menuLCID);
  117. sprm_InitLangList(hwndAudList, PRIMARYLANGID(LANGIDFROMLCID(audioLCID)));
  118. sprm_InitLangList(hwndSPList, PRIMARYLANGID(LANGIDFROMLCID(subpictureLCID)));
  119. sprm_InitLangList(hwndMenuList, PRIMARYLANGID(LANGIDFROMLCID(menuLCID)));
  120. }
  121. catch (HRESULT hr) {
  122. DVDMessageBox(hwndDlg, IDS_SPRM_FAIL);
  123. sprm_OnInitDialog(hwndDlg);
  124. return hr;
  125. }
  126. return S_OK;
  127. }
  128. /*************************************************************/
  129. /* Name: sprm_OnApply
  130. /* Description: OnApply for Viewing Options page
  131. /*************************************************************/
  132. HRESULT COptionsDlg::sprm_OnApply(HWND hwnd)
  133. {
  134. HWND hwndMenuList = ::GetDlgItem(hwnd, IDC_MENU_LANG);
  135. HWND hwndSPList = ::GetDlgItem(hwnd, IDC_SUBPIC_LANG);
  136. HWND hwndAudList = ::GetDlgItem(hwnd, IDC_AUDIO_LANG);
  137. HWND screenSaverCheck = ::GetDlgItem(hwnd, IDC_DISABLE_SCREENSAVER);
  138. HWND bookmarkOnStopCheck = ::GetDlgItem(hwnd, IDC_BOOKMARK_STOP);
  139. HWND bookmarkOnCloseCheck = ::GetDlgItem(hwnd, IDC_BOOKMARK_CLOSE);
  140. // Get current selections;
  141. INT nAudioCurSel = (INT) SendMessage(hwndAudList, CB_GETCURSEL, 0, 0);
  142. INT nMenuCurSel = (INT) SendMessage(hwndMenuList, CB_GETCURSEL, 0, 0);
  143. INT nSPCurSel = (INT) SendMessage(hwndSPList, CB_GETCURSEL, 0, 0);
  144. try {
  145. HRESULT hr = S_OK;
  146. CComPtr<IMSDVDAdm> pDvdAdm;
  147. hr = GetDvdAdm((LPVOID*) &pDvdAdm);
  148. if (FAILED(hr) || !pDvdAdm)
  149. throw(hr);
  150. if (nAudioCurSel>=0 || nMenuCurSel>=0 || nSPCurSel>=0) {
  151. BOOL bSubpictureLCIDChanged = FALSE;
  152. BOOL bAudioLCIDChanged = FALSE;
  153. BOOL bMenuLCIDChanged = FALSE;
  154. // Title default
  155. LCID subpictureLCID = (LCID)-1;
  156. LCID audioLCID = (LCID)-1;
  157. LCID menuLCID = (LCID)-1;
  158. LCID savedLCID;
  159. if (nAudioCurSel>0) {
  160. audioLCID = MAKELCID(MAKELANGID(langIDs[nAudioCurSel-1], SUBLANG_DEFAULT), SORT_DEFAULT);
  161. }
  162. pDvdAdm->get_DefaultAudioLCID((long*)&savedLCID);
  163. if (audioLCID != savedLCID) {
  164. bAudioLCIDChanged = TRUE;
  165. }
  166. if (nSPCurSel>0) {
  167. subpictureLCID = MAKELCID(MAKELANGID(langIDs[nSPCurSel-1], SUBLANG_DEFAULT), SORT_DEFAULT);
  168. }
  169. pDvdAdm->get_DefaultSubpictureLCID((long*)&savedLCID);
  170. if (subpictureLCID != savedLCID) {
  171. bSubpictureLCIDChanged = TRUE;
  172. }
  173. if (nMenuCurSel>0) {
  174. menuLCID = MAKELCID(MAKELANGID(langIDs[nMenuCurSel-1], SUBLANG_DEFAULT), SORT_DEFAULT);
  175. }
  176. pDvdAdm->get_DefaultMenuLCID((long*)&savedLCID);
  177. if (menuLCID != savedLCID) {
  178. bMenuLCIDChanged = TRUE;
  179. }
  180. if (bAudioLCIDChanged || bSubpictureLCIDChanged || bMenuLCIDChanged) {
  181. //m_pDvd->SaveState();
  182. hr = m_pDvd->Stop();
  183. if (FAILED(hr))
  184. throw (hr);
  185. if (bAudioLCIDChanged) {
  186. if (::IsValidLocale(audioLCID, LCID_SUPPORTED)){
  187. hr = m_pDvd->SelectDefaultAudioLanguage(audioLCID, 0);
  188. if (FAILED(hr))
  189. throw (hr);
  190. }
  191. hr = pDvdAdm->put_DefaultAudioLCID(audioLCID);
  192. }
  193. if (bSubpictureLCIDChanged) {
  194. if (::IsValidLocale(subpictureLCID, LCID_SUPPORTED)){
  195. hr = m_pDvd->SelectDefaultSubpictureLanguage(subpictureLCID, dvdSPExt_NotSpecified);
  196. if (FAILED(hr))
  197. throw (hr);
  198. }
  199. hr = pDvdAdm->put_DefaultSubpictureLCID(subpictureLCID);
  200. }
  201. if (bMenuLCIDChanged) {
  202. if (::IsValidLocale(menuLCID, LCID_SUPPORTED)){
  203. hr = m_pDvd->put_DefaultMenuLanguage(menuLCID);
  204. if (FAILED(hr))
  205. throw (hr);
  206. }
  207. hr = pDvdAdm->put_DefaultMenuLCID(menuLCID);
  208. }
  209. hr = m_pDvd->Play();
  210. if (FAILED(hr))
  211. throw (hr);
  212. //m_pDvd->RestoreState();
  213. }
  214. }
  215. BOOL fDisabled = (BOOL) SendMessage(screenSaverCheck, BM_GETCHECK, 0, 0);
  216. VARIANT_BOOL temp = (fDisabled==FALSE? VARIANT_FALSE:VARIANT_TRUE);
  217. hr = pDvdAdm->put_DisableScreenSaver(temp);
  218. if (FAILED(hr))
  219. throw (hr);
  220. BOOL fEnabled = (BOOL) SendMessage(bookmarkOnStopCheck, BM_GETCHECK, 0, 0);
  221. temp = (fEnabled==FALSE? VARIANT_FALSE:VARIANT_TRUE);
  222. hr = pDvdAdm->put_BookmarkOnStop(temp);
  223. if (FAILED(hr))
  224. throw (hr);
  225. fEnabled = (BOOL) SendMessage(bookmarkOnCloseCheck, BM_GETCHECK, 0, 0);
  226. temp = (fEnabled==FALSE? VARIANT_FALSE:VARIANT_TRUE);
  227. hr = pDvdAdm->put_BookmarkOnClose(temp);
  228. if (FAILED(hr))
  229. throw (hr);
  230. }
  231. catch (HRESULT hr) {
  232. DVDMessageBox(hwnd, IDS_SPRM_FAIL);
  233. sprm_OnInitDialog(hwnd);
  234. return hr;
  235. }
  236. return S_OK;
  237. }