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.

271 lines
7.4 KiB

  1. //--------------------------------------------------------------------------;
  2. //
  3. // File: playopts.cpp
  4. //
  5. // Copyright (c) 1998 Microsoft Corporation. All rights reserved
  6. //
  7. //--------------------------------------------------------------------------;
  8. #include "precomp.h"
  9. #include "optres.h"
  10. #include "cdopti.h"
  11. #include "cdoptimp.h"
  12. #include "mmsystem.h"
  13. #include "helpids.h"
  14. //////////////
  15. // Help ID's
  16. //////////////
  17. #pragma data_seg(".text")
  18. const static DWORD aPlayOptsHelp[] =
  19. {
  20. IDC_STARTPLAY, IDH_STARTPLAY,
  21. IDC_EXITSTOP, IDH_EXITSTOP,
  22. IDC_TOPMOST, IDH_TOPMOST,
  23. IDC_PLAYBACK_GROUP, IDH_PLAYBACKOPTIONS,
  24. IDC_TIMEDISPLAY_GROUP, IDH_TIMEDISPLAY,
  25. IDC_CDTIME, IDH_CDTIME,
  26. IDC_TRACKTIME, IDH_TRACKTIME,
  27. IDC_TRACKTIMEREMAIN, IDH_TRACKTIMEREMAIN,
  28. IDC_CDTIMEREMAIN, IDH_CDTIMEREMAIN,
  29. IDC_PREVIEWTIME_GROUP, IDH_PREVIEWOPTION,
  30. IDC_INTROTIMESLIDER, IDH_PREVIEWSLIDER,
  31. IDC_INTROTIMETEXT, IDH_PREVIEWDISPLAY,
  32. IDC_PREVIEWTIME_TEXT, IDH_PREVIEWOPTION,
  33. IDC_OPTIONSRESTORE, IDH_PLAYBACKDEFAULTS,
  34. IDC_SETVOLUMECNTL, IDH_SETVOLUMECONTROL,
  35. IDC_TRAYENABLE, IDH_SYSTRAY_ICON,
  36. 0, 0
  37. };
  38. #pragma data_seg()
  39. ////////////
  40. // Functions
  41. ////////////
  42. STDMETHODIMP_(void) CCDOpt::SetIntroTime(HWND hDlg)
  43. {
  44. TCHAR seconds[CDSTR];
  45. TCHAR str[CDSTR];
  46. if (m_pCDCopy)
  47. {
  48. LPCDOPTDATA pCDData = m_pCDCopy->pCDData;
  49. if (pCDData->dwIntroTime == 1)
  50. {
  51. LoadString( m_hInst, IDS_SECOND, seconds, sizeof( seconds ) /sizeof(TCHAR));
  52. }
  53. else
  54. {
  55. LoadString( m_hInst, IDS_SECONDS, seconds, sizeof( seconds ) /sizeof(TCHAR));
  56. }
  57. wsprintf(str, TEXT("%d %s"), pCDData->dwIntroTime, seconds);
  58. SetDlgItemText(hDlg, IDC_INTROTIMETEXT, str);
  59. SendDlgItemMessage( hDlg, IDC_INTROTIMESLIDER, TBM_SETPOS, TRUE, pCDData->dwIntroTime);
  60. ToggleApplyButton(hDlg);
  61. }
  62. }
  63. STDMETHODIMP_(BOOL) CCDOpt::InitPlayerOptions(HWND hDlg)
  64. {
  65. if (m_pCDCopy)
  66. {
  67. LPCDOPTDATA pCDData = m_pCDCopy->pCDData;
  68. CheckDlgButton(hDlg, IDC_STARTPLAY, pCDData->fStartPlay);
  69. CheckDlgButton(hDlg, IDC_EXITSTOP, pCDData->fExitStop);
  70. CheckDlgButton(hDlg, IDC_TOPMOST, pCDData->fTopMost);
  71. CheckDlgButton(hDlg, IDC_TRAYENABLE, pCDData->fTrayEnabled);
  72. CheckDlgButton(hDlg, IDC_TRACKTIME, pCDData->fDispMode == CDDISP_TRACKTIME);
  73. CheckDlgButton(hDlg, IDC_TRACKTIMEREMAIN, pCDData->fDispMode == CDDISP_TRACKREMAIN);
  74. CheckDlgButton(hDlg, IDC_CDTIME, pCDData->fDispMode == CDDISP_CDTIME);
  75. CheckDlgButton(hDlg, IDC_CDTIMEREMAIN, pCDData->fDispMode == CDDISP_CDREMAIN);
  76. SendDlgItemMessage( hDlg, IDC_INTROTIMESLIDER, TBM_SETRANGE, TRUE, MAKELONG( CDINTRO_MIN_TIME, CDINTRO_MAX_TIME ) );
  77. SendDlgItemMessage( hDlg, IDC_INTROTIMESLIDER, TBM_SETTICFREQ , 1, 0 );
  78. SetIntroTime(hDlg);
  79. }
  80. return TRUE;
  81. }
  82. STDMETHODIMP_(void) CCDOpt::UsePlayerDefaults(HWND hDlg)
  83. {
  84. if (m_pCDCopy)
  85. {
  86. LPCDOPTDATA pCDData = m_pCDCopy->pCDData;
  87. pCDData->fStartPlay = CDDEFAULT_START;
  88. pCDData->fExitStop = CDDEFAULT_EXIT;
  89. pCDData->fDispMode = CDDEFAULT_DISP;
  90. pCDData->fTopMost = CDDEFAULT_TOP;
  91. pCDData->fTrayEnabled = CDDEFAULT_TRAY;
  92. pCDData->dwIntroTime = CDDEFAULT_INTRO;
  93. InitPlayerOptions(hDlg);
  94. ToggleApplyButton(hDlg);
  95. }
  96. }
  97. STDMETHODIMP_(INT_PTR) CCDOpt::PlayerOptions(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
  98. {
  99. BOOL fResult = TRUE;
  100. switch (msg)
  101. {
  102. default:
  103. fResult = FALSE;
  104. break;
  105. case WM_CONTEXTMENU:
  106. {
  107. WinHelp((HWND)wParam, gszHelpFile, HELP_CONTEXTMENU, (ULONG_PTR)(LPSTR)aPlayOptsHelp);
  108. }
  109. break;
  110. case WM_HELP:
  111. {
  112. WinHelp((HWND) ((LPHELPINFO)lParam)->hItemHandle, gszHelpFile, HELP_WM_HELP, (ULONG_PTR)(LPSTR)aPlayOptsHelp);
  113. }
  114. break;
  115. case WM_INITDIALOG:
  116. {
  117. fResult = InitPlayerOptions(hDlg);
  118. }
  119. break;
  120. case WM_COMMAND:
  121. {
  122. LPCDOPTDATA pCDData = m_pCDCopy->pCDData;
  123. switch (LOWORD(wParam))
  124. {
  125. case IDC_OPTIONSRESTORE:
  126. UsePlayerDefaults(hDlg);
  127. break;
  128. case IDC_SETVOLUMECNTL:
  129. m_fVolChanged = VolumeDialog(hDlg);
  130. break;
  131. case IDC_STARTPLAY:
  132. pCDData->fStartPlay = Button_GetCheck(GetDlgItem(hDlg, IDC_STARTPLAY));
  133. ToggleApplyButton(hDlg);
  134. break;
  135. case IDC_EXITSTOP:
  136. pCDData->fExitStop = Button_GetCheck(GetDlgItem(hDlg, IDC_EXITSTOP));
  137. ToggleApplyButton(hDlg);
  138. break;
  139. case IDC_TOPMOST:
  140. pCDData->fTopMost = Button_GetCheck(GetDlgItem(hDlg, IDC_TOPMOST));
  141. ToggleApplyButton(hDlg);
  142. break;
  143. case IDC_TRAYENABLE:
  144. pCDData->fTrayEnabled = Button_GetCheck(GetDlgItem(hDlg, IDC_TRAYENABLE));
  145. ToggleApplyButton(hDlg);
  146. break;
  147. case IDC_TRACKTIME:
  148. pCDData->fDispMode = CDDISP_TRACKTIME;
  149. ToggleApplyButton(hDlg);
  150. break;
  151. case IDC_TRACKTIMEREMAIN:
  152. pCDData->fDispMode = CDDISP_TRACKREMAIN;
  153. ToggleApplyButton(hDlg);
  154. break;
  155. case IDC_CDTIME:
  156. pCDData->fDispMode = CDDISP_CDTIME;
  157. ToggleApplyButton(hDlg);
  158. break;
  159. case IDC_CDTIMEREMAIN:
  160. pCDData->fDispMode = CDDISP_CDREMAIN;
  161. ToggleApplyButton(hDlg);
  162. break;
  163. default:
  164. fResult = FALSE;
  165. break;
  166. }
  167. }
  168. break;
  169. case WM_HSCROLL:
  170. {
  171. LPCDOPTDATA pCDData = m_pCDCopy->pCDData;
  172. HWND hScroll = (HWND) lParam;
  173. if (hScroll == GetDlgItem(hDlg, IDC_INTROTIMESLIDER))
  174. {
  175. pCDData->dwIntroTime = (DWORD) SendDlgItemMessage( hDlg, IDC_INTROTIMESLIDER, TBM_GETPOS, 0, 0 );
  176. SetIntroTime(hDlg);
  177. }
  178. }
  179. break;
  180. case WM_NOTIFY:
  181. {
  182. LPNMHDR pnmh = (LPNMHDR) lParam;
  183. switch (pnmh->code)
  184. {
  185. case PSN_APPLY:
  186. {
  187. ApplyCurrentSettings();
  188. }
  189. }
  190. }
  191. break;
  192. }
  193. return fResult;
  194. }
  195. ///////////////////
  196. // Dialog handler
  197. //
  198. INT_PTR CALLBACK CCDOpt::PlayerOptionsProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
  199. {
  200. INT_PTR fResult = TRUE;
  201. CCDOpt *pCDOpt = (CCDOpt *) GetWindowLongPtr(hDlg, DWLP_USER);
  202. if (msg == WM_INITDIALOG)
  203. {
  204. pCDOpt = (CCDOpt *) ((LPPROPSHEETPAGE) lParam)->lParam;
  205. SetWindowLongPtr(hDlg, DWLP_USER, (LONG_PTR) pCDOpt);
  206. }
  207. if (pCDOpt)
  208. {
  209. fResult = pCDOpt->PlayerOptions(hDlg, msg, wParam, lParam);
  210. }
  211. if (msg == WM_DESTROY)
  212. {
  213. pCDOpt = NULL;
  214. }
  215. return(fResult);
  216. }