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.

816 lines
19 KiB

  1. #include "shellprv.h"
  2. #include "ids.h"
  3. #include "apdlg.h"
  4. #include "hwcmmn.h"
  5. #include "mtpt.h"
  6. static const DWORD s_rgdwHelpIDsArray[] =
  7. {
  8. IDC_AP_TOPTEXT, IDH_SELECT_CONTENT_TYPE,
  9. IDC_AP_LIST, IDH_SELECT_CONTENT_TYPE,
  10. IDC_AP_DEFAULTHANDLER, IDH_SELECT_ACTION,
  11. IDC_AP_LIST_ACTIONS, IDH_SELECT_ACTION,
  12. IDC_AP_PROMPTEACHTIME, IDH_PROMPT_ME_EACH_TIME,
  13. IDC_AP_NOACTION, IDH_TAKE_NO_ACTION,
  14. 0, 0
  15. };
  16. static const DWORD g_rgdwContentTypes[] =
  17. {
  18. CT_AUTOPLAYMUSIC ,
  19. CT_AUTOPLAYPIX ,
  20. CT_AUTOPLAYMOVIE ,
  21. CT_AUTOPLAYMIXEDCONTENT ,
  22. CT_CDAUDIO ,
  23. CT_DVDMOVIE ,
  24. CT_BLANKCDR , // could also have been: CT_BLANKCDRW
  25. };
  26. #define COL_ACTION 0
  27. #define COL_PROVIDER 1
  28. const UINT c_auTileColumns[] = {COL_ACTION, COL_PROVIDER};
  29. const UINT c_auTileSubItems[] = {COL_PROVIDER};
  30. HRESULT CAutoPlayDlg::_InitListViewActions()
  31. {
  32. HWND hwndList = GetDlgItem(_hwnd, IDC_AP_LIST_ACTIONS);
  33. HRESULT hr = _uilListViewActions.Init(hwndList);
  34. if (SUCCEEDED(hr))
  35. {
  36. hr = _uilListViewActions.InitTileInfo(c_auTileSubItems, ARRAYSIZE(c_auTileSubItems));
  37. if (SUCCEEDED(hr))
  38. {
  39. RECT rc = {0};
  40. LVTILEVIEWINFO lvtvi = {0};
  41. HIMAGELIST himagelist;
  42. ListView_SetView(hwndList, LV_VIEW_TILE);
  43. for (int i = 0; i < ARRAYSIZE(c_auTileColumns); ++i)
  44. {
  45. LVCOLUMN lvcolumn = {0};
  46. lvcolumn.mask = LVCF_SUBITEM;
  47. lvcolumn.iSubItem = c_auTileColumns[i];
  48. ListView_InsertColumn(hwndList, i, &lvcolumn);
  49. }
  50. GetClientRect(hwndList, &rc);
  51. lvtvi.cbSize = sizeof(lvtvi);
  52. lvtvi.dwMask = LVTVIM_TILESIZE | LVTVIM_COLUMNS;
  53. lvtvi.dwFlags = LVTVIF_FIXEDWIDTH;
  54. // Leave room for the scroll bar when setting tile sizes or listview gets screwed up.
  55. lvtvi.sizeTile.cx = ((rc.right - rc.left) - GetSystemMetrics(SM_CXVSCROLL));
  56. lvtvi.cLines = ARRAYSIZE(c_auTileSubItems);
  57. ListView_SetTileViewInfo(hwndList, &lvtvi);
  58. Shell_GetImageLists(&himagelist, NULL);
  59. if (himagelist)
  60. {
  61. ListView_SetImageList(hwndList, himagelist, LVSIL_NORMAL);
  62. hr = S_OK;
  63. }
  64. }
  65. }
  66. return hr;
  67. }
  68. HRESULT CAutoPlayDlg::_FillListViewActions(CContentTypeData* pdata)
  69. {
  70. HRESULT hr = _uilListViewActions.ResetContent();
  71. if (SUCCEEDED(hr))
  72. {
  73. int c = pdata->GetHandlerCount();
  74. if (c)
  75. {
  76. for (int i = 0; SUCCEEDED(hr) && (i < c); ++i)
  77. {
  78. CHandlerData* phandlerdata = pdata->GetHandlerData(i);
  79. if (phandlerdata)
  80. {
  81. CHandlerLVItem* puidata = new CHandlerLVItem();
  82. if (puidata)
  83. {
  84. hr = puidata->InitData(phandlerdata);
  85. if (SUCCEEDED(hr))
  86. {
  87. hr = _uilListViewActions.AddItem(puidata);
  88. if (FAILED(hr))
  89. {
  90. delete puidata;
  91. }
  92. }
  93. }
  94. else
  95. {
  96. hr = E_OUTOFMEMORY;
  97. }
  98. phandlerdata->Release();
  99. }
  100. }
  101. _fAtLeastOneAction = TRUE;
  102. }
  103. else
  104. {
  105. // disable the listview and its radio button
  106. _fAtLeastOneAction = FALSE;
  107. }
  108. }
  109. return hr;
  110. }
  111. HRESULT CAutoPlayDlg::_UpdateRestoreButton(BOOL fPromptEachTime)
  112. {
  113. BOOL fEnable;
  114. if (fPromptEachTime)
  115. {
  116. fEnable = FALSE;
  117. }
  118. else
  119. {
  120. fEnable = TRUE;
  121. }
  122. EnableWindow(GetDlgItem(_hwnd, IDC_AP_RESTOREDEFAULTS), fEnable);
  123. return fEnable;
  124. }
  125. HRESULT CAutoPlayDlg::_UpdateLowerPane()
  126. {
  127. CContentTypeData* pdata;
  128. HRESULT hr = _uilListView.GetSelectedItemData(&pdata);
  129. _fIgnoreListViewItemStateChanges = TRUE;
  130. if (SUCCEEDED(hr))
  131. {
  132. BOOL fPromptEachTime = !lstrcmpi(pdata->_pszHandlerDefault, TEXT("MSPromptEachTime"));
  133. if (!fPromptEachTime)
  134. {
  135. if (!(pdata->_dwHandlerDefaultFlags & HANDLERDEFAULT_USERCHOSENDEFAULT))
  136. {
  137. // There *NO* User Chosen Default
  138. fPromptEachTime = TRUE;
  139. }
  140. else
  141. {
  142. // There is a User Chosen Default
  143. if (pdata->_dwHandlerDefaultFlags &
  144. HANDLERDEFAULT_MORERECENTHANDLERSINSTALLED)
  145. {
  146. // But there's also more recent apps
  147. fPromptEachTime = TRUE;
  148. }
  149. }
  150. }
  151. hr = _FillListViewActions(pdata);
  152. if (SUCCEEDED(hr))
  153. {
  154. hr = _SelectListViewActionsItem(pdata->_pszHandlerDefault);
  155. }
  156. if (SUCCEEDED(hr))
  157. {
  158. hr = _SelectRadioButton(fPromptEachTime);
  159. }
  160. if (SUCCEEDED(hr))
  161. {
  162. hr = _UpdateRestoreButton(fPromptEachTime);
  163. }
  164. pdata->Release();
  165. }
  166. _fIgnoreListViewItemStateChanges = FALSE;
  167. return hr;
  168. }
  169. HRESULT CAutoPlayDlg::_UpdateApplyButton()
  170. {
  171. if (_dlmanager.IsDirty())
  172. {
  173. PropSheet_Changed(GetParent(_hwnd), _hwnd);
  174. }
  175. else
  176. {
  177. PropSheet_UnChanged(GetParent(_hwnd), _hwnd);
  178. }
  179. return S_OK;
  180. }
  181. HRESULT _SetHandlerDefault(LPWSTR* ppszHandlerDefault, LPCWSTR pszHandler)
  182. {
  183. LPWSTR pszHandlerNew;
  184. HRESULT hr = SHStrDup(pszHandler, &pszHandlerNew);
  185. if (SUCCEEDED(hr))
  186. {
  187. if (*ppszHandlerDefault)
  188. {
  189. CoTaskMemFree(*ppszHandlerDefault);
  190. }
  191. *ppszHandlerDefault = pszHandlerNew;
  192. }
  193. return hr;
  194. }
  195. HRESULT CAutoPlayDlg::_SelectRadioButton(BOOL fPromptEachTime)
  196. {
  197. CContentTypeData* pdata;
  198. HRESULT hr = _uilListView.GetSelectedItemData(&pdata);
  199. if (SUCCEEDED(hr))
  200. {
  201. int iCtrl;
  202. BOOL fEnableListView = FALSE;
  203. if (fPromptEachTime)
  204. {
  205. _SetHandlerDefault(&(pdata->_pszHandlerDefault), TEXT("MSPromptEachTime"));
  206. iCtrl = IDC_AP_PROMPTEACHTIME;
  207. }
  208. else
  209. {
  210. fEnableListView = TRUE;
  211. CHandlerData* phandlerdata;
  212. hr = _uilListViewActions.GetSelectedItemData(&phandlerdata);
  213. if (SUCCEEDED(hr))
  214. {
  215. _SetHandlerDefault(&(pdata->_pszHandlerDefault), phandlerdata->_pszHandler);
  216. phandlerdata->Release();
  217. }
  218. iCtrl = IDC_AP_DEFAULTHANDLER;
  219. }
  220. Button_SetCheck(GetDlgItem(_hwnd, IDC_AP_DEFAULTHANDLER), (IDC_AP_DEFAULTHANDLER == iCtrl));
  221. Button_SetCheck(GetDlgItem(_hwnd, IDC_AP_PROMPTEACHTIME), (IDC_AP_PROMPTEACHTIME == iCtrl));
  222. EnableWindow(GetDlgItem(_hwnd, IDC_AP_LIST_ACTIONS), fEnableListView);
  223. pdata->Release();
  224. hr = _UpdateApplyButton();
  225. }
  226. return hr;
  227. }
  228. HRESULT CAutoPlayDlg::_SelectListViewActionsItem(LPCWSTR pszHandlerDefault)
  229. {
  230. HRESULT hr = S_FALSE;
  231. LVITEM lvitem = {0};
  232. int iItemToSelect = 0;
  233. HWND hwndList = GetDlgItem(_hwnd, IDC_AP_LIST_ACTIONS);
  234. if (pszHandlerDefault)
  235. {
  236. int c = ListView_GetItemCount(hwndList);
  237. if (c)
  238. {
  239. int i;
  240. for (i = 0; i < c; ++i)
  241. {
  242. lvitem.mask = LVIF_PARAM;
  243. lvitem.iItem = i;
  244. if (ListView_GetItem(hwndList, &lvitem))
  245. {
  246. CHandlerLVItem* phandleruidata = (CHandlerLVItem*)lvitem.lParam;
  247. if (phandleruidata)
  248. {
  249. CHandlerData* phandlerdata = phandleruidata->GetData();
  250. if (phandlerdata)
  251. {
  252. if (!lstrcmp(phandlerdata->_pszHandler,
  253. pszHandlerDefault))
  254. {
  255. break;
  256. }
  257. phandlerdata->Release();
  258. }
  259. }
  260. }
  261. }
  262. if (i == c)
  263. {
  264. i = 0;
  265. }
  266. else
  267. {
  268. hr = S_OK;
  269. }
  270. iItemToSelect = i;
  271. }
  272. }
  273. else
  274. {
  275. // Select first one
  276. hr = S_OK;
  277. }
  278. lvitem.mask = LVIF_STATE;
  279. lvitem.iItem = iItemToSelect;
  280. lvitem.stateMask = LVIS_SELECTED | LVIS_FOCUSED;
  281. lvitem.state = LVIS_SELECTED | LVIS_FOCUSED;
  282. ListView_SetItem(hwndList, &lvitem);
  283. ListView_EnsureVisible(hwndList, lvitem.iItem, FALSE);
  284. return hr;
  285. }
  286. void _SetCtrlTextFromResourceText(HWND hwndDlg, int iCtrl, int iResourceText)
  287. {
  288. // We use 256, even if we would use a bigger buffer, the ctrl where we'll
  289. // put the text would probably not be able to take it anyway (would be
  290. // truncated).
  291. WCHAR sz[256];
  292. if (LoadString(HINST_THISDLL, iResourceText, sz, ARRAYSIZE(sz)))
  293. {
  294. SetDlgItemText(hwndDlg, iCtrl, sz);
  295. }
  296. }
  297. LRESULT CAutoPlayDlg::_OnApply()
  298. {
  299. if (_dlmanager.IsDirty())
  300. {
  301. // Should we get the return value, and if so, why?
  302. _dlmanager.Commit();
  303. }
  304. return PSNRET_NOERROR;
  305. }
  306. // Listview Actions
  307. HRESULT CAutoPlayDlg::_OnListViewActionsSelChange()
  308. {
  309. CHandlerData* phandlerdata;
  310. HRESULT hr = _uilListViewActions.GetSelectedItemData(&phandlerdata);
  311. if (SUCCEEDED(hr))
  312. {
  313. CContentTypeData* pdata;
  314. hr = _uilListView.GetSelectedItemData(&pdata);
  315. if (SUCCEEDED(hr))
  316. {
  317. _SetHandlerDefault(&(pdata->_pszHandlerDefault), phandlerdata->_pszHandler);
  318. pdata->Release();
  319. }
  320. phandlerdata->Release();
  321. }
  322. if (SUCCEEDED(hr))
  323. {
  324. hr = _UpdateApplyButton();
  325. }
  326. return hr;
  327. }
  328. // Radio buttons
  329. HRESULT CAutoPlayDlg::_OnRestoreDefault()
  330. {
  331. CContentTypeData* pdata;
  332. HRESULT hr = _uilListView.GetSelectedItemData(&pdata);
  333. if (SUCCEEDED(hr))
  334. {
  335. _SetHandlerDefault(&(pdata->_pszHandlerDefault), TEXT("MSPromptEachTime"));
  336. _SelectRadioButton(TRUE);
  337. hr = _UpdateApplyButton();
  338. if (SUCCEEDED(hr))
  339. {
  340. _UpdateRestoreButton(TRUE);
  341. }
  342. pdata->Release();
  343. SetFocus(GetNextDlgTabItem(_hwnd, GetDlgItem(_hwnd, IDC_AP_RESTOREDEFAULTS), FALSE /*next ctrl*/));
  344. }
  345. return hr;
  346. }
  347. HRESULT CAutoPlayDlg::_OnRadio(int iButton)
  348. {
  349. CContentTypeData* pdata;
  350. HRESULT hr = _uilListView.GetSelectedItemData(&pdata);
  351. if (SUCCEEDED(hr))
  352. {
  353. HWND hwndList = GetDlgItem(_hwnd, IDC_AP_LIST_ACTIONS);
  354. if (IDC_AP_DEFAULTHANDLER == iButton)
  355. {
  356. CHandlerData* phandlerdata;
  357. EnableWindow(hwndList, TRUE);
  358. hr = _uilListViewActions.GetSelectedItemData(&phandlerdata);
  359. if (SUCCEEDED(hr))
  360. {
  361. _SetHandlerDefault(&(pdata->_pszHandlerDefault), phandlerdata->_pszHandler);
  362. phandlerdata->Release();
  363. }
  364. }
  365. else
  366. {
  367. _SetHandlerDefault(&(pdata->_pszHandlerDefault), TEXT("MSPromptEachTime"));
  368. EnableWindow(hwndList, FALSE);
  369. }
  370. hr = _UpdateApplyButton();
  371. if (SUCCEEDED(hr))
  372. {
  373. _UpdateRestoreButton(!lstrcmpi(pdata->_pszHandlerDefault, TEXT("MSPromptEachTime")));
  374. }
  375. pdata->Release();
  376. }
  377. return hr;
  378. }
  379. LRESULT CAutoPlayDlg::OnInitDialog(WPARAM wParam, LPARAM lParam)
  380. {
  381. HRESULT hr = _InitDataObjects();
  382. _fIgnoreListViewItemStateChanges = TRUE;
  383. if (SUCCEEDED(hr))
  384. {
  385. hr = _InitListView();
  386. if (SUCCEEDED(hr))
  387. {
  388. hr = _FillListView();
  389. if (SUCCEEDED(hr))
  390. {
  391. hr = _InitListViewActions();
  392. if (SUCCEEDED(hr))
  393. {
  394. hr = _uilListView.SelectFirstItem();
  395. if (SUCCEEDED(hr))
  396. {
  397. hr = _UpdateLowerPane();
  398. }
  399. }
  400. }
  401. }
  402. }
  403. _fIgnoreListViewItemStateChanges = FALSE;
  404. return TRUE;
  405. }
  406. LRESULT CAutoPlayDlg::OnNotify(WPARAM wParam, LPARAM lParam)
  407. {
  408. LRESULT lRes = FALSE;
  409. LPNMHDR pNMHDR = (LPNMHDR)lParam;
  410. UINT_PTR idFrom = pNMHDR->idFrom;
  411. UINT uCode = pNMHDR->code;
  412. switch (uCode)
  413. {
  414. case PSN_APPLY:
  415. lRes = _OnApply();
  416. CBaseDlg::OnNotify(wParam, lParam);
  417. break;
  418. default:
  419. switch (idFrom)
  420. {
  421. case IDC_AP_LIST_ACTIONS:
  422. if (!_fIgnoreListViewItemStateChanges)
  423. {
  424. NMLISTVIEW* pNMLV = (NMLISTVIEW*)pNMHDR;
  425. if (LVN_ITEMCHANGED == uCode)
  426. {
  427. // Is a new item being selected?
  428. if ((pNMLV->uChanged & LVIF_STATE) &&
  429. pNMLV->uNewState & LVIS_SELECTED)
  430. {
  431. _OnListViewActionsSelChange();
  432. }
  433. }
  434. }
  435. lRes = CBaseDlg::OnNotify(wParam, lParam);
  436. break;
  437. default:
  438. lRes = CBaseDlg::OnNotify(wParam, lParam);
  439. break;
  440. }
  441. break;
  442. }
  443. return lRes;
  444. }
  445. LRESULT CAutoPlayDlg::OnCommand(WPARAM wParam, LPARAM lParam)
  446. {
  447. int iCtl = LOWORD(wParam);
  448. int iNot = HIWORD(wParam);
  449. switch (iCtl)
  450. {
  451. case IDC_AP_DEFAULTHANDLER:
  452. case IDC_AP_PROMPTEACHTIME:
  453. if (BN_CLICKED == iNot)
  454. {
  455. _OnRadio(iCtl);
  456. }
  457. break;
  458. case IDC_AP_LIST:
  459. if (HIWORD(wParam) == CBN_SELCHANGE)
  460. {
  461. _UpdateLowerPane();
  462. }
  463. break;
  464. case IDC_AP_RESTOREDEFAULTS:
  465. if (BN_CLICKED == iNot)
  466. {
  467. _OnRestoreDefault();
  468. }
  469. break;
  470. }
  471. return CBaseDlg::OnCommand(wParam, lParam);
  472. }
  473. LRESULT CAutoPlayDlg::OnDestroy(WPARAM wParam, LPARAM lParam)
  474. {
  475. _uilListView.ResetContent();
  476. _uilListViewActions.ResetContent();
  477. return CBaseDlg::OnDestroy(wParam, lParam);
  478. }
  479. LRESULT CAutoPlayDlg::OnHelp(WPARAM wParam, LPARAM lParam)
  480. {
  481. HWND hwndItem = (HWND)((LPHELPINFO)lParam)->hItemHandle;
  482. BOOL ret = WinHelp(hwndItem, TEXT("filefold.hlp"), HELP_WM_HELP, (ULONG_PTR)(LPTSTR)s_rgdwHelpIDsArray);
  483. if (!ret)
  484. {
  485. return CBaseDlg::OnHelp(wParam, lParam);
  486. }
  487. return ret;
  488. }
  489. LRESULT CAutoPlayDlg::OnContextMenu(WPARAM wParam, LPARAM lParam)
  490. {
  491. BOOL lRes=FALSE;
  492. if (HTCLIENT == (int)SendMessage(_hwnd, WM_NCHITTEST, 0, lParam))
  493. {
  494. POINT pt;
  495. HWND hwndItem = NULL;
  496. int iCtrlID = 0;
  497. pt.x = GET_X_LPARAM(lParam);
  498. pt.y = GET_Y_LPARAM(lParam);
  499. ScreenToClient(_hwnd, &pt);
  500. hwndItem = ChildWindowFromPoint(_hwnd, pt);
  501. iCtrlID = GetDlgCtrlID(hwndItem);
  502. lRes = WinHelp((HWND)wParam, TEXT("filefold.hlp"), HELP_CONTEXTMENU, (ULONG_PTR)(LPTSTR)s_rgdwHelpIDsArray);
  503. if (!lRes)
  504. {
  505. return CBaseDlg::OnContextMenu(wParam, lParam);
  506. }
  507. }
  508. else
  509. {
  510. lRes = FALSE;
  511. }
  512. return lRes;
  513. }
  514. CAutoPlayDlg::CAutoPlayDlg() : CBaseDlg((ULONG_PTR)s_rgdwHelpIDsArray)
  515. {
  516. ASSERT(ARRAYSIZE(_rgpContentTypeData) >= ARRAYSIZE(g_rgdwContentTypes));
  517. }
  518. HRESULT CAutoPlayDlg::Init(LPWSTR pszDrive, int iDriveType)
  519. {
  520. lstrcpyn(_szDrive, pszDrive, ARRAYSIZE(_szDrive));
  521. _iDriveType = iDriveType;
  522. return S_OK;
  523. }
  524. HRESULT CAutoPlayDlg::_InitDataObjects()
  525. {
  526. HRESULT hr = S_FALSE;
  527. BOOL fIsCDDrive = FALSE;
  528. DWORD dwDriveCapabilities = HWDDC_CDROM;
  529. DWORD dwMediaCapabilities = HWDMC_CDROM;
  530. CMountPoint* pmtpt = CMountPoint::GetMountPoint(_szDrive);
  531. if (pmtpt)
  532. {
  533. fIsCDDrive = pmtpt->IsCDROM();
  534. if (fIsCDDrive)
  535. {
  536. hr = pmtpt->GetCDInfo(&dwDriveCapabilities, &dwMediaCapabilities);
  537. }
  538. pmtpt->Release();
  539. }
  540. for (DWORD dw = 0; SUCCEEDED(hr) && (dw < ARRAYSIZE(g_rgdwContentTypes));
  541. ++dw)
  542. {
  543. BOOL fAddOption = TRUE;
  544. if (fIsCDDrive)
  545. {
  546. if ((g_rgdwContentTypes[dw] & CT_DVDMOVIE) &&
  547. !(dwDriveCapabilities & (HWDDC_DVDROM | HWDDC_DVDRECORDABLE | HWDDC_DVDREWRITABLE)))
  548. {
  549. fAddOption = FALSE;
  550. }
  551. else if ((g_rgdwContentTypes[dw] & CT_BLANKCDR) &&
  552. !(dwDriveCapabilities & (HWDDC_CDRECORDABLE | HWDDC_CDREWRITABLE)))
  553. {
  554. fAddOption = FALSE;
  555. }
  556. }
  557. else
  558. {
  559. if (g_rgdwContentTypes[dw] &
  560. (CT_CDAUDIO | CT_DVDMOVIE | CT_BLANKCDR))
  561. {
  562. fAddOption = FALSE;
  563. }
  564. }
  565. if (fAddOption)
  566. {
  567. _rgpContentTypeData[dw] = new CContentTypeData();
  568. if (_rgpContentTypeData[dw])
  569. {
  570. hr = (_rgpContentTypeData[dw])->Init(_szDrive, g_rgdwContentTypes[dw]);
  571. if (SUCCEEDED(hr))
  572. {
  573. hr = _dlmanager.AddDataObject(_rgpContentTypeData[dw]);
  574. }
  575. else
  576. {
  577. // Let's just skip this one, do not go out of the loop and
  578. // abort the whole initialization.
  579. hr = S_FALSE;
  580. }
  581. }
  582. else
  583. {
  584. hr = E_OUTOFMEMORY;
  585. }
  586. }
  587. }
  588. return hr;
  589. }
  590. HRESULT CAutoPlayDlg::_InitListView()
  591. {
  592. HWND hwndList = GetDlgItem(_hwnd, IDC_AP_LIST);
  593. HRESULT hr = _uilListView.Init(hwndList);
  594. if (SUCCEEDED(hr))
  595. {
  596. Shell_GetImageLists(NULL, &_himagelist);
  597. if (_himagelist)
  598. {
  599. SendMessage(hwndList, CBEM_SETIMAGELIST, 0, (LPARAM)_himagelist);
  600. hr = S_OK;
  601. }
  602. }
  603. return hr;
  604. }
  605. HRESULT CAutoPlayDlg::_FillListView()
  606. {
  607. HRESULT hr = S_FALSE;
  608. for (DWORD dw = 0; SUCCEEDED(hr) && (dw < ARRAYSIZE(_rgpContentTypeData));
  609. ++dw)
  610. {
  611. if (_rgpContentTypeData[dw])
  612. {
  613. CContentTypeCBItem* pctlvitem = new CContentTypeCBItem();
  614. if (pctlvitem)
  615. {
  616. hr = pctlvitem->InitData(_rgpContentTypeData[dw]);
  617. if (SUCCEEDED(hr))
  618. {
  619. hr = _uilListView.AddItem(pctlvitem);
  620. }
  621. if (FAILED(hr))
  622. {
  623. delete pctlvitem;
  624. }
  625. }
  626. else
  627. {
  628. hr = E_OUTOFMEMORY;
  629. }
  630. }
  631. }
  632. return hr;
  633. }
  634. CAutoPlayDlg::~CAutoPlayDlg()
  635. {
  636. for (DWORD dw = 0; dw < ARRAYSIZE(_rgpContentTypeData); ++dw)
  637. {
  638. if (_rgpContentTypeData[dw])
  639. {
  640. (_rgpContentTypeData[dw])->Release();
  641. }
  642. }
  643. #ifdef AUTOPLAYDLG_LEAKPARANOIA
  644. // If this is on, you cannot open two Autoplay dialogs (e.g.: Autoplay
  645. // proppage and Autoplay prompt) at the same time and then close one.
  646. // It will assert for sure when you close the first one.
  647. ASSERT(!_DbgLocalAllocCount);
  648. #endif
  649. }