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.

600 lines
19 KiB

  1. // COptionsDlg.cpp : Declaration of the COptionsDlg class
  2. //
  3. // Copyright (C) 1999 Microsoft Corporation
  4. // All rights reserved.
  5. #include "stdafx.h"
  6. #include "COptDlg.h"
  7. #include "resource.hm"
  8. extern CComModule _Module;
  9. #define RECTWIDTH(lpRect) ((lpRect)->right - (lpRect)->left)
  10. #define RECTHEIGHT(lpRect) ((lpRect)->bottom - (lpRect)->top)
  11. int g_helpIDArraySize = 42;
  12. DWORD g_helpIDArray[][2] = {
  13. {IDOK, HIDOK},
  14. {IDCANCEL, HIDCANCEL},
  15. {IDC_APPLY, HIDAPPLY},
  16. {IDC_AUDIO_LIST, HIDC_AUDIO_LIST},
  17. {IDC_STATIC_AUDIO_LIST, HIDC_AUDIO_LIST},
  18. {IDC_STATIC_CHAN_CONTENT, HIDC_CHECK_CHAN2},
  19. {IDC_CHECK_CHAN2, HIDC_CHECK_CHAN2},
  20. {IDC_CHECK_CHAN3, HIDC_CHECK_CHAN2},
  21. {IDC_CHECK_CHAN4, HIDC_CHECK_CHAN2},
  22. {IDC_BOOKMARK_STOP, HIDC_BOOKMARK_STOP},
  23. {IDC_BOOKMARK_CLOSE, HIDC_BOOKMARK_CLOSE},
  24. {IDC_SUBPIC_LANG, HIDC_SUBPIC_LANG},
  25. {IDC_AUDIO_LANG, HIDC_AUDIO_LANG},
  26. {IDC_MENU_LANG, HIDC_MENU_LANG},
  27. {IDC_STATIC_SUBPIC_LANG, HIDC_SUBPIC_LANG},
  28. {IDC_STATIC_AUDIO_LANG, HIDC_AUDIO_LANG},
  29. {IDC_STATIC_MENU_LANG, HIDC_MENU_LANG},
  30. {IDC_EDIT_PASSWORD, HIDC_EDIT_PASSWORD},
  31. {IDC_STATIC_PASSWORD, HIDC_EDIT_PASSWORD},
  32. {IDC_EDIT_NEW_PASSWORD, HIDC_EDIT_NEW_PASSWORD},
  33. {IDC_STATIC_NEW_PASSWORD, HIDC_EDIT_NEW_PASSWORD},
  34. {IDC_EDIT_CONFIRM_NEW, HIDC_EDIT_CONFIRM_NEW},
  35. {IDC_STATIC_CONFIRM_NEW, HIDC_EDIT_CONFIRM_NEW},
  36. {IDC_COMBO_RATE, HIDC_COMBO_RATE},
  37. {IDC_STATIC_CURRENT_RATE, HIDC_COMBO_RATE},
  38. {IDC_BUTTON_CHANGE_PASSWORD, HIDC_BUTTON_CHANGE_PASSWORD},
  39. {IDC_DISABLE_PARENT, HIDC_DISABLE_PARENT},
  40. {IDC_DISABLE_SCREENSAVER, HIDC_DISABLE_SCREENSAVER},
  41. {IDC_LIST_TITLES, HIDC_LIST_TITLES},
  42. {IDC_LIST_CHAPS, HIDC_LIST_CHAPS},
  43. {IDC_STATIC_LIST_TITLES, HIDC_LIST_TITLES},
  44. {IDC_STATIC_LIST_CHAPS, HIDC_LIST_CHAPS},
  45. };
  46. /*************************************************************/
  47. /* Name: Constructor
  48. /* Description:
  49. /*************************************************************/
  50. COptionsDlg::COptionsDlg(IMSWebDVD* pDvd)
  51. {
  52. m_pDvd = pDvd;
  53. m_dFFSpeed = 16.0;
  54. m_dBWSpeed = 16.0;
  55. m_dPlaySpeed = 1.0;
  56. m_bChapDirty = FALSE;
  57. m_bDirty = FALSE;
  58. m_pDvdOpt = NULL;
  59. m_pPasswordDlg = NULL;
  60. for (int i=0; i<C_PAGES; i++) {
  61. m_hwndDisplay[i] = NULL;
  62. }
  63. }
  64. /*************************************************************/
  65. /* Name:
  66. /* Description:
  67. /*************************************************************/
  68. COptionsDlg::~COptionsDlg() {
  69. if (m_pDvd) {
  70. m_pDvd.Release();
  71. m_pDvd = NULL;
  72. }
  73. if (m_pPasswordDlg) {
  74. delete m_pPasswordDlg;
  75. m_pPasswordDlg = NULL;
  76. }
  77. }
  78. /*************************************************************/
  79. /* Name: IsNewAdmin
  80. /* Description: TRUE if no admin password hasn't been enter
  81. /* FALSE otherwise
  82. /*************************************************************/
  83. BOOL COptionsDlg::IsNewAdmin()
  84. {
  85. BOOL bNewAdmin = TRUE;
  86. TCHAR szSavedPasswd[MAX_PASSWD+PRE_PASSWD];
  87. DWORD dwLen = MAX_PASSWD+PRE_PASSWD;
  88. BOOL bFound = GetRegistryString(g_szPassword, szSavedPasswd, &dwLen, TEXT(""));
  89. if (bFound && dwLen != 0)
  90. bNewAdmin = FALSE;
  91. return bNewAdmin;
  92. }
  93. /*************************************************************/
  94. /* Name: OnInitDialog
  95. /* Description: Create tab control
  96. /*************************************************************/
  97. LRESULT COptionsDlg::OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
  98. {
  99. m_pDvdOpt->Fire_OnOpen();
  100. m_bChapDirty = FALSE;
  101. m_bDirty = FALSE;
  102. ::EnableWindow(GetDlgItem(IDC_APPLY), FALSE);
  103. // Save itself in the window user data
  104. // so that child dialog proc can use it
  105. ::SetWindowLongPtr(m_hWnd, GWLP_USERDATA, (LONG_PTR)this);
  106. SetFont((HFONT) GetStockObject(ANSI_FIXED_FONT), TRUE);
  107. DWORD dwDlgBase = GetDialogBaseUnits();
  108. int cxMargin = LOWORD(dwDlgBase) / 4;
  109. int cyMargin = HIWORD(dwDlgBase) / 8;
  110. cxMargin *= 2;
  111. cyMargin *= 2;
  112. m_hwndTab = GetDlgItem(IDC_TABCTRL);
  113. TabCtrl_DeleteAllItems(m_hwndTab);
  114. for (int i=C_PAGES-1; i>=0; i--) {
  115. m_hwndDisplay[i] = NULL;
  116. }
  117. TCITEM tie;
  118. // Add a tab for each of the three child dialog boxes.
  119. tie.mask = TCIF_TEXT | TCIF_IMAGE;
  120. tie.iImage = -1;
  121. RECT rcTab;
  122. SetRectEmpty(&rcTab);
  123. for (i=0; i<C_PAGES; i++) {
  124. tie.pszText = LoadStringFromRes(IDS_SEARCH+i);
  125. TabCtrl_InsertItem(m_hwndTab, i, &tie);
  126. // Lock the resources for the child dialog boxes.
  127. m_apRes[i] = DoLockDlgRes(MAKEINTRESOURCE(IDD_SEARCH+i));
  128. // Determine the bounding rectangle for all child dialog boxes.
  129. SIZE size;
  130. AtlGetDialogSize(m_apRes[i], &size);
  131. if (size.cx > rcTab.right)
  132. rcTab.right = size.cx;
  133. if (size.cy > rcTab.bottom)
  134. rcTab.bottom = size.cy;
  135. }
  136. // Calculate how large to make the tab control, so
  137. // the display area can accommodate all the child dialog boxes.
  138. TabCtrl_AdjustRect(m_hwndTab, TRUE, &rcTab);
  139. OffsetRect(&rcTab,
  140. GetSystemMetrics(SM_CXDLGFRAME) + cxMargin - rcTab.left,
  141. GetSystemMetrics(SM_CYDLGFRAME) + cyMargin - rcTab.top);
  142. // Calculate the display rectangle.
  143. RECT rcDisplay;
  144. CopyRect(&rcDisplay, &rcTab);
  145. TabCtrl_AdjustRect(m_hwndTab, FALSE, &rcDisplay);
  146. OffsetRect(&rcDisplay, cxMargin, cyMargin);
  147. // Set the size and position of the tab control, buttons,
  148. // and dialog box.
  149. ::MoveWindow(m_hwndTab,
  150. rcTab.left, rcTab.top,
  151. RECTWIDTH(&rcTab) + 2*cxMargin,
  152. RECTHEIGHT(&rcTab) + 2*cyMargin,
  153. TRUE);
  154. // Size the dialog box.
  155. RECT rcButton = {0, 0, 50, 14};
  156. HWND hWndButton = GetDlgItem(IDC_APPLY);
  157. if (hWndButton) {
  158. ::GetClientRect(hWndButton, &rcButton);
  159. }
  160. RECT rcDialog;
  161. GetWindowRect(&rcDialog);
  162. MoveWindow(rcDialog.left, rcDialog.top,
  163. rcTab.right + 4*cxMargin + 2*GetSystemMetrics(SM_CXDLGFRAME),
  164. rcTab.bottom + 6*cyMargin + 2*GetSystemMetrics(SM_CYDLGFRAME)
  165. + RECTHEIGHT(&rcButton) + GetSystemMetrics(SM_CYCAPTION),
  166. TRUE);
  167. // Move the apply, cancel and ok buttons
  168. GetClientRect(&rcDialog);
  169. // apply button
  170. if (hWndButton) {
  171. ::MoveWindow(hWndButton,
  172. RECTWIDTH(&rcDialog)-2*cxMargin-RECTWIDTH(&rcButton),
  173. RECTHEIGHT(&rcDialog)-2*cyMargin-RECTHEIGHT(&rcButton),
  174. RECTWIDTH(&rcButton),
  175. RECTHEIGHT(&rcButton),
  176. TRUE);
  177. }
  178. // cancel button
  179. hWndButton = GetDlgItem(IDCANCEL);
  180. if (hWndButton) {
  181. ::MoveWindow(hWndButton,
  182. RECTWIDTH(&rcDialog)-3*cxMargin-2*RECTWIDTH(&rcButton),
  183. RECTHEIGHT(&rcDialog)-2*cyMargin-RECTHEIGHT(&rcButton),
  184. RECTWIDTH(&rcButton),
  185. RECTHEIGHT(&rcButton),
  186. TRUE);
  187. }
  188. // ok button
  189. hWndButton = GetDlgItem(IDOK);
  190. if (hWndButton) {
  191. ::MoveWindow(hWndButton,
  192. RECTWIDTH(&rcDialog)-4*cxMargin-3*RECTWIDTH(&rcButton),
  193. RECTHEIGHT(&rcDialog)-2*cyMargin-RECTHEIGHT(&rcButton),
  194. RECTWIDTH(&rcButton),
  195. RECTHEIGHT(&rcButton),
  196. TRUE);
  197. }
  198. // Create individual pages
  199. for (i=C_PAGES-1; i>=0; i--) {
  200. m_hwndDisplay[i] = CreateDialogIndirect(_Module.GetModuleInstance(),
  201. m_apRes[i], m_hWnd, ChildDialogProc);
  202. ::MoveWindow(m_hwndDisplay[i],
  203. rcDisplay.left,
  204. rcDisplay.top,
  205. RECTWIDTH(&rcDisplay),
  206. RECTHEIGHT(&rcDisplay),
  207. TRUE);
  208. }
  209. // Simulate selection of the first item.
  210. m_currentSel = 0;
  211. OnSelChanged();
  212. return 0;
  213. }
  214. /*************************************************************/
  215. /* Name: OnNotify
  216. /* Description: Tab control selection has changed
  217. /*************************************************************/
  218. LRESULT COptionsDlg::OnNotify(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
  219. {
  220. NMHDR *lpnmhdr = (LPNMHDR) lParam;
  221. switch (lpnmhdr->code) {
  222. case TCN_SELCHANGE:
  223. OnSelChanged();
  224. break;
  225. }
  226. return 0;
  227. }
  228. /*************************************************************/
  229. /* Name: DoLockDlgRes */
  230. /* Description: loads and locks a dialog template resource. */
  231. /* Returns the address of the locked resource. */
  232. /* lpszResName - name of the resource */
  233. /*************************************************************/
  234. DLGTEMPLATE * WINAPI COptionsDlg::DoLockDlgRes(LPCTSTR lpszResName){
  235. HRSRC hrsrc = FindResource(_Module.GetModuleInstance(), lpszResName, RT_DIALOG);
  236. if(NULL == hrsrc){
  237. ATLASSERT(FALSE);
  238. return(NULL);
  239. }/* end of if statement */
  240. HGLOBAL hglb = LoadResource(_Module.GetModuleInstance(), hrsrc);
  241. return (DLGTEMPLATE *) LockResource(hglb);
  242. } /* end of function DoLockDlgRes */
  243. /*************************************************************/
  244. /* Name: OnSelChanged
  245. /* Description: processes the TCN_SELCHANGE notification.
  246. hwndDlg - handle to the parent dialog box.
  247. /*************************************************************/
  248. VOID WINAPI COptionsDlg::OnSelChanged()
  249. {
  250. int iSel = TabCtrl_GetCurSel(m_hwndTab);
  251. // hide current dialog box
  252. ::ShowWindow(m_hwndDisplay[m_currentSel], SW_HIDE);
  253. ::ShowWindow(m_hwndDisplay[iSel], SW_SHOW);
  254. if(iSel == PAGE_PG && IsNewAdmin()) //first time login
  255. {
  256. OnDoPasswordDlg(CPasswordDlg::PASSWORDDLG_CHANGE);
  257. }
  258. m_currentSel = iSel;
  259. }
  260. /*************************************************************/
  261. /* Name: OnHelp
  262. /* Description: Display help message for a control
  263. /*************************************************************/
  264. LRESULT COptionsDlg::OnHelp(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
  265. {
  266. HELPINFO *lphi = (LPHELPINFO) lParam;
  267. HWND hwnd = (HWND) lphi->hItemHandle;
  268. DWORD_PTR contextId = lphi->dwContextId;
  269. if (contextId != 0) {
  270. if (contextId >= HIDOK)
  271. ::WinHelp(m_hWnd, TEXT("windows.hlp"), HELP_CONTEXTPOPUP, contextId);
  272. else
  273. ::WinHelp(m_hWnd, TEXT("dvdplay.hlp"), HELP_CONTEXTPOPUP, contextId);
  274. }
  275. return 0;
  276. }
  277. /*************************************************************/
  278. /* Name: OnContextMenu
  279. /* Description: Display help message for a control
  280. /*************************************************************/
  281. LRESULT COptionsDlg::OnContextMenu(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
  282. {
  283. HWND hwnd = (HWND) wParam;
  284. DWORD controlId = ::GetDlgCtrlID(hwnd);
  285. POINT pt;
  286. pt.x = GET_X_LPARAM(lParam);
  287. pt.y = GET_Y_LPARAM(lParam);
  288. if (controlId == 0) {
  289. ::ScreenToClient(hwnd, &pt);
  290. hwnd = ::ChildWindowFromPoint(hwnd, pt);
  291. controlId = ::GetDlgCtrlID(hwnd);
  292. }
  293. for (int i=0; i<g_helpIDArraySize; i++) {
  294. if (controlId && controlId == g_helpIDArray[i][0]) {
  295. if (controlId <= IDC_APPLY) {
  296. ::WinHelp(hwnd, TEXT("windows.hlp"), HELP_CONTEXTMENU, (DWORD_PTR)g_helpIDArray);
  297. return 0;
  298. }
  299. else {
  300. ::WinHelp(hwnd, TEXT("dvdplay.hlp"), HELP_CONTEXTMENU, (DWORD_PTR)g_helpIDArray);
  301. return 0;
  302. }
  303. }
  304. }
  305. return 0;
  306. }
  307. /*************************************************************/
  308. /* Name: OnApply
  309. /* Description:
  310. /*************************************************************/
  311. LRESULT COptionsDlg::OnApply(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
  312. {
  313. bHandled = FALSE;
  314. // apply changes in all pages
  315. if (m_hwndDisplay[PAGE_CHAP])
  316. chapSrch_OnApply(m_hwndDisplay[PAGE_CHAP]);
  317. if (m_hwndDisplay[PAGE_SPRM])
  318. sprm_OnApply(m_hwndDisplay[PAGE_SPRM]);
  319. if (m_hwndDisplay[PAGE_PG])
  320. pg_OnApply(m_hwndDisplay[PAGE_PG]);
  321. if (m_hwndDisplay[PAGE_KARAOKE])
  322. karaoke_OnApply(m_hwndDisplay[PAGE_KARAOKE]);
  323. otherPage_Dirty(FALSE);
  324. ::EnableWindow(GetDlgItem(IDC_APPLY), FALSE);
  325. return 1;
  326. }
  327. /*************************************************************/
  328. /* Name: OnOK
  329. /* Description:
  330. /*************************************************************/
  331. LRESULT COptionsDlg::OnOK(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
  332. {
  333. OnApply(wNotifyCode, wID, hWndCtl, bHandled);
  334. m_pDvdOpt->Fire_OnClose();
  335. EndDialog(wID);
  336. return 0;
  337. }
  338. /*************************************************************/
  339. /* Name: OnEndDialog
  340. /* Description:
  341. /*************************************************************/
  342. LRESULT COptionsDlg::OnEndDialog(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
  343. {
  344. m_pDvdOpt->Fire_OnClose();
  345. EndDialog(wID);
  346. return 0;
  347. }
  348. /*************************************************************/
  349. /* Name: OnActivate
  350. /* Description: called when the change/verify password dlg dimisses
  351. /*************************************************************/
  352. LRESULT COptionsDlg::OnActivate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
  353. {
  354. if (WA_ACTIVE != LOWORD(wParam))
  355. return 0;
  356. HWND tabControl = GetDlgItem(IDC_TABCTRL);
  357. if (!tabControl)
  358. return 0;
  359. int iSel = TabCtrl_GetCurSel(m_hwndTab);
  360. if (iSel == PAGE_PG) {
  361. if (!m_pPasswordDlg)
  362. return 0;
  363. if ( m_pPasswordDlg->GetReason() == CPasswordDlg::PASSWORDDLG_VERIFY) {
  364. // If password verification succeded
  365. if (m_pPasswordDlg->IsVerified())
  366. ShowRestartWarning(m_hwndDisplay[PAGE_PG]);
  367. else
  368. pg_OnInitDialog(m_hwndDisplay[PAGE_PG]);
  369. }
  370. }
  371. return 0;
  372. }
  373. /*************************************************************/
  374. /* Name: ShowRestartWarning
  375. /* Description:
  376. /*************************************************************/
  377. void COptionsDlg::ShowRestartWarning(HWND hwndDlg)
  378. {
  379. HWND staticWarning = ::GetDlgItem(hwndDlg, IDC_WARNING_RESTART);
  380. if (!staticWarning) return;
  381. ::ShowWindow(staticWarning, SW_SHOW);
  382. }
  383. /*************************************************************/
  384. /* Name: OnChangePassword
  385. /* Description:
  386. /*************************************************************/
  387. HRESULT COptionsDlg::OnDoPasswordDlg(CPasswordDlg::PASSWORDDLG_REASON reason)
  388. {
  389. HRESULT hr = S_OK;
  390. if (!m_pPasswordDlg) {
  391. CComPtr<IMSDVDAdm> pDvdAdm;
  392. hr = GetDvdAdm((LPVOID*) &pDvdAdm);
  393. if (FAILED(hr) || !pDvdAdm) return hr;
  394. m_pPasswordDlg = new CPasswordDlg(pDvdAdm);
  395. }
  396. m_pPasswordDlg->SetReason(reason);
  397. m_pPasswordDlg->DoModal(m_hwndDisplay[PAGE_PG]);
  398. return hr;
  399. }
  400. /*************************************************************/
  401. /* Name: ChildDialogProc
  402. /* Description: DialogProc for the control tabs
  403. /*************************************************************/
  404. INT_PTR CALLBACK ChildDialogProc(
  405. HWND hwndDlg, // handle to the child dialog box
  406. UINT uMsg, // message
  407. WPARAM wParam, // first message parameter
  408. LPARAM lParam // second message parameter
  409. )
  410. {
  411. HWND hwndParent = GetParent(hwndDlg);
  412. COptionsDlg *pDlgOpt = (COptionsDlg *)::GetWindowLongPtr
  413. (hwndParent, GWLP_USERDATA);
  414. switch(uMsg) {
  415. case WM_INITDIALOG:
  416. {
  417. pDlgOpt->chapSrch_OnInitDialog(hwndDlg);
  418. pDlgOpt->sprm_OnInitDialog(hwndDlg);
  419. pDlgOpt->pg_OnInitDialog(hwndDlg);
  420. if (FAILED(pDlgOpt->karaoke_OnInitDialog(hwndDlg))) {
  421. HWND hwndTab = ::GetDlgItem(hwndParent, IDC_TABCTRL);
  422. TabCtrl_DeleteItem(hwndTab, PAGE_ABOUT);
  423. TabCtrl_DeleteItem(hwndTab, PAGE_KARAOKE);
  424. // Add back the about page
  425. TCITEM tie;
  426. tie.mask = TCIF_TEXT | TCIF_IMAGE;
  427. tie.iImage = -1;
  428. tie.pszText = LoadStringFromRes(IDS_ABOUT);
  429. TabCtrl_InsertItem(hwndTab, PAGE_KARAOKE, &tie);
  430. pDlgOpt->m_hwndDisplay[PAGE_KARAOKE] = pDlgOpt->m_hwndDisplay[PAGE_ABOUT];
  431. }
  432. return TRUE;
  433. }
  434. case WM_COMMAND: {
  435. CComPtr<IMSWebDVD> pDvd;
  436. HRESULT hr = pDlgOpt->GetDvd(&pDvd);
  437. if (FAILED(hr) || !pDvd)
  438. return FALSE;
  439. switch (HIWORD(wParam)) {
  440. case BN_CLICKED:
  441. switch(LOWORD(wParam)) {
  442. case IDC_BUTTON_CHANGE_PASSWORD:
  443. pDlgOpt->OnDoPasswordDlg(CPasswordDlg::PASSWORDDLG_CHANGE);
  444. break;
  445. case IDC_DISABLE_PARENT: {
  446. // Return value < 32 bits. Easier to cast than to change to LRESULT
  447. // all over the code.
  448. BOOL disableParent = (BOOL)::SendMessage((HWND)lParam, BM_GETCHECK, 0, 0);
  449. ::EnableWindow(::GetDlgItem(hwndDlg, IDC_COMBO_RATE), !disableParent);
  450. pDlgOpt->OnDoPasswordDlg(CPasswordDlg::PASSWORDDLG_VERIFY);
  451. }
  452. // Fall through
  453. default:
  454. pDlgOpt->otherPage_Dirty(TRUE);
  455. ::EnableWindow(::GetDlgItem(hwndParent, IDC_APPLY), TRUE);
  456. break;
  457. }
  458. break;
  459. case LBN_SELCHANGE:
  460. switch(LOWORD(wParam)) {
  461. case IDC_SUBPIC_LANG:
  462. case IDC_AUDIO_LANG:
  463. case IDC_MENU_LANG:
  464. pDlgOpt->ShowRestartWarning(hwndDlg);
  465. pDlgOpt->otherPage_Dirty(TRUE);
  466. ::EnableWindow(::GetDlgItem(hwndParent, IDC_APPLY), TRUE);
  467. break;
  468. case IDC_COMBO_RATE:
  469. pDlgOpt->OnDoPasswordDlg(CPasswordDlg::PASSWORDDLG_VERIFY);
  470. pDlgOpt->otherPage_Dirty(TRUE);
  471. ::EnableWindow(::GetDlgItem(hwndParent, IDC_APPLY), TRUE);
  472. break;
  473. case IDC_AUDIO_LIST:
  474. pDlgOpt->karaoke_InitChannelList(hwndDlg);
  475. ::EnableWindow(::GetDlgItem(hwndParent, IDC_APPLY), TRUE);
  476. break;
  477. case IDC_LIST_TITLES:
  478. pDlgOpt->chapSrch_InitChapList(hwndDlg);
  479. // Fall through
  480. case IDC_LIST_CHAPS:
  481. pDlgOpt->chapSrch_Dirty(TRUE);
  482. ::EnableWindow(::GetDlgItem(hwndParent, IDC_APPLY), TRUE);
  483. break;
  484. default:
  485. pDlgOpt->otherPage_Dirty(TRUE);
  486. ::EnableWindow(::GetDlgItem(hwndParent, IDC_APPLY), TRUE);
  487. break;
  488. }
  489. break;
  490. case LBN_DBLCLK:
  491. switch(LOWORD(wParam)) {
  492. case IDC_LIST_TITLES:
  493. ::SendMessage(::GetDlgItem(hwndDlg, IDC_LIST_CHAPS), LB_SETCURSEL, (WPARAM)-1, 0);
  494. // Fall through
  495. case IDC_LIST_CHAPS:
  496. pDlgOpt->chapSrch_Dirty(TRUE);
  497. pDlgOpt->chapSrch_OnApply(hwndDlg);
  498. // If no other page is dirty, disable the apply button
  499. if (!pDlgOpt->otherPage_Dirty())
  500. ::EnableWindow(::GetDlgItem(hwndParent, IDC_APPLY), FALSE);
  501. break;
  502. case IDC_AUDIO_LIST:
  503. pDlgOpt->karaoke_OnApply(hwndDlg);
  504. // If no other page is dirty, disable the apply button
  505. if (!pDlgOpt->otherPage_Dirty())
  506. ::EnableWindow(::GetDlgItem(hwndParent, IDC_APPLY), FALSE);
  507. break;
  508. }
  509. break;
  510. }
  511. return FALSE;
  512. }
  513. }
  514. return FALSE;
  515. }