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.

915 lines
22 KiB

  1. #include "shellprv.h"
  2. #include "ids.h"
  3. #include "apprmdlg.h"
  4. #include "mtpt.h"
  5. #include "hwcmmn.h"
  6. #include "mixctnt.h"
  7. static DWORD s_rgdwHelpIDsArray[] =
  8. { // Context Help IDs
  9. IDC_AP_MXCT_TOPICON, NO_HELP,
  10. IDC_AP_MXCT_TOPTEXT, NO_HELP,
  11. IDC_AP_MXCT_TOPTEXT2, NO_HELP,
  12. IDC_AP_MXCT_LIST, NO_HELP,
  13. IDC_AP_MXCT_CHECKBOX, NO_HELP,
  14. 0, 0
  15. };
  16. CBaseContentDlg::CBaseContentDlg() : CBaseDlg((ULONG_PTR)s_rgdwHelpIDsArray),
  17. _pszDeviceID(NULL), _hiconInfo(NULL), _hiconTop(NULL)
  18. {}
  19. CBaseContentDlg::~CBaseContentDlg()
  20. {
  21. if (_pszDeviceID)
  22. {
  23. LocalFree((HLOCAL)_pszDeviceID);
  24. }
  25. if (_hiconInfo)
  26. {
  27. DestroyIcon(_hiconInfo);
  28. }
  29. if (_hiconTop)
  30. {
  31. DestroyIcon(_hiconTop);
  32. }
  33. }
  34. HRESULT CBaseContentDlg::_SetHandler()
  35. {
  36. CHandlerData* phandlerdata;
  37. HRESULT hr = _uilListView.GetSelectedItemData(&phandlerdata);
  38. if (SUCCEEDED(hr))
  39. {
  40. lstrcpyn(_szHandler, phandlerdata->_pszHandler,
  41. ARRAYSIZE(_szHandler));
  42. phandlerdata->Release();
  43. }
  44. return hr;
  45. }
  46. HRESULT CBaseContentDlg::Init(LPCWSTR pszDeviceID, LPCWSTR pszDeviceIDAlt,
  47. DWORD dwContentType, BOOL fCheckAlwaysDoThis)
  48. {
  49. HRESULT hr = E_INVALIDARG;
  50. _fCheckAlwaysDoThis = fCheckAlwaysDoThis;
  51. if (pszDeviceID)
  52. {
  53. _pszDeviceID = StrDup(pszDeviceID);
  54. if (_pszDeviceID)
  55. {
  56. _szDeviceIDAlt[0] = 0;
  57. if (pszDeviceIDAlt)
  58. {
  59. if (InRange(*pszDeviceIDAlt, 'a', 'z') ||
  60. InRange(*pszDeviceIDAlt, 'A', 'Z'))
  61. {
  62. lstrcpyn(_szDeviceIDAlt, pszDeviceIDAlt,
  63. ARRAYSIZE(_szDeviceIDAlt));
  64. _dwContentType = dwContentType;
  65. hr = _GetContentTypeHandler(dwContentType, _szContentTypeHandler,
  66. ARRAYSIZE(_szContentTypeHandler));
  67. }
  68. }
  69. hr = S_OK;
  70. }
  71. else
  72. {
  73. hr = E_OUTOFMEMORY;
  74. }
  75. }
  76. return hr;
  77. }
  78. #define COL_ACTION 0
  79. #define COL_PROVIDER 1
  80. const UINT c_auTileColumns[] = {COL_ACTION, COL_PROVIDER};
  81. const UINT c_auTileSubItems[] = {COL_PROVIDER};
  82. HRESULT CBaseContentDlg::_InitListView()
  83. {
  84. HWND hwndList = GetDlgItem(_hwnd, IDC_AP_MXCT_LIST);
  85. HRESULT hr = _uilListView.Init(hwndList);
  86. if (SUCCEEDED(hr))
  87. {
  88. hr = _uilListView.InitTileInfo(c_auTileSubItems, ARRAYSIZE(c_auTileSubItems));
  89. if (SUCCEEDED(hr))
  90. {
  91. RECT rc = {0};
  92. LVTILEVIEWINFO lvtvi = {0};
  93. HIMAGELIST himagelist;
  94. ListView_SetView(hwndList, LV_VIEW_TILE);
  95. for (int i = 0; i < ARRAYSIZE(c_auTileColumns); ++i)
  96. {
  97. LVCOLUMN lvcolumn = {0};
  98. lvcolumn.mask = LVCF_SUBITEM;
  99. lvcolumn.iSubItem = c_auTileColumns[i];
  100. ListView_InsertColumn(hwndList, i, &lvcolumn);
  101. }
  102. GetClientRect(hwndList, &rc);
  103. lvtvi.cbSize = sizeof(LVTILEVIEWINFO);
  104. lvtvi.dwMask = LVTVIM_TILESIZE | LVTVIM_COLUMNS;
  105. lvtvi.dwFlags = LVTVIF_FIXEDWIDTH;
  106. // Leave room for the scroll bar when setting tile sizes or listview gets screwed up.
  107. lvtvi.sizeTile.cx = ((rc.right - rc.left) - GetSystemMetrics(SM_CXVSCROLL));
  108. lvtvi.cLines = ARRAYSIZE(c_auTileSubItems);
  109. ListView_SetTileViewInfo(hwndList, &lvtvi);
  110. Shell_GetImageLists(&himagelist, NULL);
  111. if (himagelist)
  112. {
  113. ListView_SetImageList(hwndList, himagelist, LVSIL_NORMAL);
  114. hr = S_OK;
  115. }
  116. }
  117. }
  118. return hr;
  119. }
  120. LRESULT CBaseContentDlg::OnInitDialog(WPARAM wParam, LPARAM lParam)
  121. {
  122. HRESULT hr = _InitListView();
  123. if (SUCCEEDED(hr))
  124. {
  125. hr = _FillListView();
  126. if (SUCCEEDED(hr))
  127. {
  128. hr = _InitStaticsCommon();
  129. if (SUCCEEDED(hr))
  130. {
  131. hr = _InitStatics();
  132. if (SUCCEEDED(hr))
  133. {
  134. hr = _InitSelections();
  135. }
  136. }
  137. }
  138. }
  139. if (_szDeviceIDAlt[0])
  140. {
  141. _SetAutoplayPromptHWND(_szDeviceIDAlt, _hwnd);
  142. }
  143. return TRUE;
  144. }
  145. LRESULT CBaseContentDlg::OnNotify(WPARAM wParam, LPARAM lParam)
  146. {
  147. LRESULT lRes = FALSE;
  148. LPNMHDR pNMHDR = (NMHDR *)lParam;
  149. UINT_PTR idFrom = pNMHDR->idFrom;
  150. UINT uCode = pNMHDR->code;
  151. switch (idFrom)
  152. {
  153. case IDC_AP_MXCT_LIST:
  154. if (LVN_ITEMCHANGED == uCode)
  155. {
  156. NMLISTVIEW* pNMLV = (NMLISTVIEW*)pNMHDR;
  157. // Is a new item being selected/unselected?
  158. if (pNMLV->uChanged & LVIF_STATE)
  159. {
  160. // Yes
  161. _OnListSelChange();
  162. }
  163. }
  164. else if (NM_DBLCLK == uCode)
  165. {
  166. OnOK(0);
  167. }
  168. lRes = CBaseDlg::OnNotify(wParam, lParam);
  169. break;
  170. default:
  171. lRes = CBaseDlg::OnNotify(wParam, lParam);
  172. break;
  173. }
  174. return lRes;
  175. }
  176. LRESULT CBaseContentDlg::OnDestroy(WPARAM wParam, LPARAM lParam)
  177. {
  178. _uilListView.ResetContent();
  179. return CBaseDlg::OnDestroy(wParam, lParam);
  180. }
  181. LRESULT CBaseContentDlg::OnOK(WORD wNotif)
  182. {
  183. // Wait cursor...
  184. EndDialog(_hwnd, IDOK);
  185. return FALSE;
  186. }
  187. LRESULT CBaseContentDlg::OnCancel(WORD wNotif)
  188. {
  189. EndDialog(_hwnd, IDCANCEL);
  190. return FALSE;
  191. }
  192. HRESULT CBaseContentDlg::_InitStaticsCommon()
  193. {
  194. // Initialize _szDeviceName to something
  195. HRESULT hr = _InitDeviceName();
  196. if (SUCCEEDED(hr))
  197. {
  198. SetWindowText(_hwnd, _szDeviceName);
  199. }
  200. if (_fCheckAlwaysDoThis)
  201. {
  202. Button_SetCheck(GetDlgItem(_hwnd, IDC_AP_MXCT_CHECKBOX), _fCheckAlwaysDoThis);
  203. }
  204. if (_szDeviceIDAlt[0])
  205. {
  206. // Initialize _szDeviceName to something
  207. CMountPoint* pmtpt = CMountPoint::GetMountPoint(_szDeviceIDAlt);
  208. if (pmtpt)
  209. {
  210. WCHAR szIconLocation[MAX_PATH + 12];
  211. int iIcon = pmtpt->GetIcon(szIconLocation, ARRAYSIZE(szIconLocation));
  212. if (SUCCEEDED(hr))
  213. {
  214. if (!szIconLocation[0])
  215. {
  216. lstrcpy(szIconLocation, TEXT("shell32.dll"));
  217. }
  218. int iImage = Shell_GetCachedImageIndex(szIconLocation, iIcon, 0);
  219. HIMAGELIST himagelist;
  220. if ((-1 != iImage) && Shell_GetImageLists(&himagelist, NULL))
  221. {
  222. _hiconTop = ImageList_GetIcon(himagelist, iImage, ILD_TRANSPARENT);
  223. SendDlgItemMessage(_hwnd, IDC_AP_MXCT_TOPICON, STM_SETIMAGE,
  224. IMAGE_ICON, (LPARAM)_hiconTop);
  225. }
  226. }
  227. pmtpt->Release();
  228. }
  229. }
  230. return hr;
  231. }
  232. HRESULT CBaseContentDlg::_InitDeviceName()
  233. {
  234. HRESULT hr = E_FAIL;
  235. if (_szDeviceIDAlt[0])
  236. {
  237. CMountPoint* pmtpt = CMountPoint::GetMountPoint(_szDeviceIDAlt);
  238. if (pmtpt)
  239. {
  240. hr = pmtpt->GetDisplayName(_szDeviceName, ARRAYSIZE(_szDeviceName));
  241. pmtpt->Release();
  242. }
  243. }
  244. if (FAILED(hr))
  245. {
  246. GetWindowText(_hwnd, _szDeviceName, ARRAYSIZE(_szDeviceName));
  247. hr = S_FALSE;
  248. }
  249. return hr;
  250. }
  251. ///////////////////////////////////////////////////////////////////////////////
  252. CHWContentPromptDlg::CHWContentPromptDlg() : CBaseContentDlg()
  253. {}
  254. CHWContentPromptDlg::~CHWContentPromptDlg()
  255. {}
  256. HRESULT CHWContentPromptDlg::_InitDataObjects()
  257. {
  258. HRESULT hr = _data.Init(_pszDeviceID, _dwContentType);
  259. if (SUCCEEDED(hr))
  260. {
  261. hr = _dlmanager.AddDataObject(&_data);
  262. }
  263. return hr;
  264. }
  265. HRESULT CHWContentPromptDlg::_FillListView()
  266. {
  267. HRESULT hr = _InitDataObjects();
  268. if (SUCCEEDED(hr))
  269. {
  270. int c = _data.GetHandlerCount();
  271. for (int i = 0; SUCCEEDED(hr) && (i < c); ++i)
  272. {
  273. CHandlerData* phandlerdata = _data.GetHandlerData(i);
  274. if (phandlerdata)
  275. {
  276. CHandlerLVItem* puidata = new CHandlerLVItem();
  277. if (puidata)
  278. {
  279. hr = puidata->InitData(phandlerdata);
  280. if (SUCCEEDED(hr))
  281. {
  282. hr = _uilListView.AddItem(puidata);
  283. }
  284. if (FAILED(hr))
  285. {
  286. delete puidata;
  287. }
  288. }
  289. else
  290. {
  291. hr = E_OUTOFMEMORY;
  292. }
  293. phandlerdata->Release();
  294. }
  295. }
  296. }
  297. return hr;
  298. }
  299. HRESULT CHWContentPromptDlg::_InitStatics()
  300. {
  301. // Set content icon
  302. if (_hiconTop)
  303. {
  304. DestroyIcon(_hiconTop);
  305. }
  306. _hiconTop = _GetIconFromIconLocation(_data._szIconLocation, FALSE);
  307. SendDlgItemMessage(_hwnd, IDC_AP_MXCT_CONTENTICON, STM_SETIMAGE,
  308. IMAGE_ICON, (LPARAM)_hiconTop);
  309. // Set content name
  310. SetDlgItemText(_hwnd, IDC_AP_MXCT_CONTENTTYPE, _data._szIconLabel);
  311. return S_OK;
  312. }
  313. HRESULT CHWContentPromptDlg::_InitSelections()
  314. {
  315. HRESULT hr;
  316. if (_data._pszHandlerDefaultOriginal && *(_data._pszHandlerDefaultOriginal))
  317. {
  318. hr = _uilListView.SelectItem(_data._pszHandlerDefaultOriginal);
  319. }
  320. else
  321. {
  322. hr = _uilListView.SelectFirstItem();
  323. }
  324. if (SUCCEEDED(hr))
  325. {
  326. CHandlerData* phandlerdata;
  327. hr = _uilListView.GetSelectedItemData(&phandlerdata);
  328. if (SUCCEEDED(hr))
  329. {
  330. lstrcpyn(_szHandler, phandlerdata->_pszHandler,
  331. ARRAYSIZE(_szHandler));
  332. _SetHandlerDefault(&(_data._pszHandlerDefault), phandlerdata->_pszHandler);
  333. phandlerdata->Release();
  334. }
  335. }
  336. Button_SetCheck(GetDlgItem(_hwnd, IDC_AP_MXCT_CHECKBOX), _fCheckAlwaysDoThis);
  337. return hr;
  338. }
  339. HRESULT CHWContentPromptDlg::_UpdateHandlerSettings()
  340. {
  341. CHandlerData* phandlerdata;
  342. HRESULT hr = _uilListView.GetSelectedItemData(&phandlerdata);
  343. if (SUCCEEDED(hr))
  344. {
  345. _SetHandlerDefault(&(_data._pszHandlerDefault), phandlerdata->_pszHandler);
  346. phandlerdata->Release();
  347. }
  348. return hr;
  349. }
  350. HRESULT CHWContentPromptDlg::_OnListSelChange()
  351. {
  352. return _UpdateHandlerSettings();
  353. }
  354. LRESULT CHWContentPromptDlg::OnOK(WORD wNotif)
  355. {
  356. if (BST_CHECKED == Button_GetCheck(GetDlgItem(_hwnd, IDC_AP_MXCT_CHECKBOX)))
  357. {
  358. _SaveSettings(FALSE);
  359. // return value????
  360. }
  361. else
  362. {
  363. _SaveSettings(TRUE);
  364. }
  365. _SetHandler();
  366. // Do default processing
  367. return CBaseContentDlg::OnOK(wNotif);
  368. }
  369. HRESULT CHWContentPromptDlg::_SaveSettings(BOOL fSoftCommit)
  370. {
  371. _data._fSoftCommit = fSoftCommit;
  372. return _dlmanager.Commit();
  373. }
  374. CMixedContentDlg::CMixedContentDlg() : _dpaContentTypeData(NULL)
  375. {
  376. }
  377. CMixedContentDlg::~CMixedContentDlg()
  378. {
  379. if (_dpaContentTypeData)
  380. {
  381. int c = _dpaContentTypeData.GetPtrCount();
  382. for (int i = 0; i < c; ++i)
  383. {
  384. CContentTypeData* pdata = _dpaContentTypeData.GetPtr(i);
  385. pdata->Release();
  386. }
  387. _dpaContentTypeData.Destroy();
  388. }
  389. }
  390. const DWORD c_rgdwContentTypeAutoplay[] =
  391. {
  392. CT_AUTOPLAYMUSIC,
  393. CT_AUTOPLAYPIX,
  394. CT_AUTOPLAYMOVIE,
  395. };
  396. HRESULT CMixedContentDlg::_InitDataObjects()
  397. {
  398. HRESULT hr = _dpaContentTypeData.Create(4) ? S_OK : E_OUTOFMEMORY;
  399. if (SUCCEEDED(hr))
  400. {
  401. for (DWORD dw = 0; dw < ARRAYSIZE(c_rgdwContentTypeAutoplay); ++dw)
  402. {
  403. if (_dwContentType & c_rgdwContentTypeAutoplay[dw])
  404. {
  405. CContentTypeData* pdata = new CContentTypeData();
  406. if (pdata)
  407. {
  408. hr = pdata->Init(_pszDeviceID, _dwContentType & c_rgdwContentTypeAutoplay[dw]);
  409. if (SUCCEEDED(hr))
  410. {
  411. if (-1 == _dpaContentTypeData.AppendPtr(pdata))
  412. {
  413. hr = E_OUTOFMEMORY;
  414. }
  415. }
  416. if (FAILED(hr))
  417. {
  418. pdata->Release();
  419. }
  420. }
  421. else
  422. {
  423. hr = E_OUTOFMEMORY;
  424. }
  425. }
  426. }
  427. if (SUCCEEDED(hr))
  428. {
  429. // Eliminate the duplicates. Go thru all the content types
  430. // and then thru all their handlers and see if their would
  431. // not be two duplicate handlers that were brought by two diff
  432. // content type. E.g.: Open folder is registered for music,
  433. // pictures and video
  434. int cContentType = _dpaContentTypeData.GetPtrCount();
  435. for (int iContentType = 0; iContentType < cContentType; ++iContentType)
  436. {
  437. CContentTypeData* pdata = _dpaContentTypeData.GetPtr(iContentType);
  438. if (pdata)
  439. {
  440. int cHandler = pdata->GetHandlerCount();
  441. for (int iHandler = 0; iHandler < cHandler; ++iHandler)
  442. {
  443. CHandlerData* phandlerdata = pdata->GetHandlerData(iHandler);
  444. if (phandlerdata)
  445. {
  446. for (int iContentTypeInner = 0;
  447. iContentTypeInner < cContentType;
  448. ++iContentTypeInner)
  449. {
  450. BOOL fExitInnerLoop = FALSE;
  451. // Cannot have duplicate handler within same content type
  452. if (iContentTypeInner != iContentType)
  453. {
  454. CContentTypeData* pdataInner = _dpaContentTypeData.GetPtr(iContentTypeInner);
  455. if (pdataInner)
  456. {
  457. int cHandlerInner = pdataInner->GetHandlerCount();
  458. for (int iHandlerInner = 0;
  459. !fExitInnerLoop && (iHandlerInner < cHandlerInner);
  460. ++iHandlerInner)
  461. {
  462. CHandlerData* phandlerdataInner = pdataInner->GetHandlerData(iHandlerInner);
  463. if (phandlerdataInner)
  464. {
  465. if (!lstrcmp(phandlerdataInner->_pszHandler,
  466. phandlerdata->_pszHandler))
  467. {
  468. pdataInner->RemoveHandler(iHandlerInner);
  469. // Can be only one duplicate for a
  470. // handler within another content type
  471. fExitInnerLoop = TRUE;
  472. }
  473. phandlerdataInner->Release();
  474. }
  475. }
  476. }
  477. }
  478. }
  479. phandlerdata->Release();
  480. }
  481. }
  482. }
  483. }
  484. }
  485. }
  486. else
  487. {
  488. hr = E_OUTOFMEMORY;
  489. }
  490. return hr;
  491. }
  492. HRESULT CMixedContentDlg::_FillListView()
  493. {
  494. HRESULT hr = _InitDataObjects();
  495. if (SUCCEEDED(hr))
  496. {
  497. if (_dpaContentTypeData)
  498. {
  499. int c = _dpaContentTypeData.GetPtrCount();
  500. for (int i = 0; SUCCEEDED(hr) && (i < c); ++i)
  501. {
  502. CContentTypeData* pdata = _dpaContentTypeData.GetPtr(i);
  503. if (pdata)
  504. {
  505. pdata->AddRef();
  506. int cHandler = pdata->GetHandlerCount();
  507. for (int j = 0; SUCCEEDED(hr) && (j < cHandler); ++j)
  508. {
  509. CHandlerData* phandlerdata = pdata->GetHandlerData(j);
  510. if (phandlerdata)
  511. {
  512. CHandlerLVItem* puidata = new CHandlerLVItem();
  513. if (puidata)
  514. {
  515. hr = puidata->InitData(phandlerdata);
  516. if (SUCCEEDED(hr))
  517. {
  518. hr = _uilListView.AddItem(puidata);
  519. }
  520. if (FAILED(hr))
  521. {
  522. delete puidata;
  523. }
  524. }
  525. else
  526. {
  527. hr = E_OUTOFMEMORY;
  528. }
  529. phandlerdata->Release();
  530. }
  531. }
  532. pdata->Release();
  533. }
  534. }
  535. }
  536. }
  537. return hr;
  538. }
  539. HRESULT CMixedContentDlg::_InitStatics()
  540. {
  541. return S_OK;
  542. }
  543. HRESULT CMixedContentDlg::_InitSelections()
  544. {
  545. HRESULT hr = _uilListView.SelectFirstItem();
  546. if (SUCCEEDED(hr))
  547. {
  548. CHandlerData* phandlerdata;
  549. hr = _uilListView.GetSelectedItemData(&phandlerdata);
  550. if (SUCCEEDED(hr))
  551. {
  552. lstrcpyn(_szHandler, phandlerdata->_pszHandler,
  553. ARRAYSIZE(_szHandler));
  554. phandlerdata->Release();
  555. }
  556. }
  557. return hr;
  558. }
  559. HRESULT CMixedContentDlg::_OnListSelChange()
  560. {
  561. return S_OK;
  562. }
  563. LRESULT CMixedContentDlg::OnOK(WORD wNotif)
  564. {
  565. _SetHandler();
  566. if (_dpaContentTypeData)
  567. {
  568. BOOL fFound = FALSE;
  569. int c = _dpaContentTypeData.GetPtrCount();
  570. for (int i = 0; !fFound && (i < c); ++i)
  571. {
  572. CContentTypeData* pdata = _dpaContentTypeData.GetPtr(i);
  573. if (pdata)
  574. {
  575. pdata->AddRef();
  576. int cHandler = pdata->GetHandlerCount();
  577. for (int j = 0; !fFound && (j < cHandler); ++j)
  578. {
  579. CHandlerData* phandlerdata = pdata->GetHandlerData(j);
  580. if (phandlerdata)
  581. {
  582. if (!lstrcmp(phandlerdata->_pszHandler,
  583. _szHandler))
  584. {
  585. lstrcpyn(_szContentTypeHandler,
  586. pdata->_szContentTypeHandler,
  587. ARRAYSIZE(_szContentTypeHandler));
  588. fFound = TRUE;
  589. }
  590. phandlerdata->Release();
  591. }
  592. }
  593. pdata->Release();
  594. }
  595. }
  596. }
  597. // Do default processing
  598. return CBaseContentDlg::OnOK(wNotif);
  599. }
  600. ///////////////////////////////////////////////////////////////////////////////
  601. ///////////////////////////////////////////////////////////////////////////////
  602. ///////////////////////////////////////////////////////////////////////////////
  603. CNoContentDlg::CNoContentDlg() : CBaseContentDlg()
  604. {}
  605. CNoContentDlg::~CNoContentDlg()
  606. {}
  607. HRESULT CNoContentDlg::_InitDataObjects()
  608. {
  609. HRESULT hr = _data.Init(_pszDeviceID);
  610. if (SUCCEEDED(hr))
  611. {
  612. hr = _dlmanager.AddDataObject(&_data);
  613. }
  614. _SetAutoplayPromptHWND(_pszDeviceID, _hwnd);
  615. return hr;
  616. }
  617. HRESULT CNoContentDlg::_FillListView()
  618. {
  619. HRESULT hr = _InitDataObjects();
  620. if (SUCCEEDED(hr))
  621. {
  622. int c = _data.GetHandlerCount();
  623. for (int i = 0; SUCCEEDED(hr) && (i < c); ++i)
  624. {
  625. CHandlerData* phandlerdata = _data.GetHandlerData(i);
  626. if (phandlerdata)
  627. {
  628. CHandlerLVItem* puidata = new CHandlerLVItem();
  629. if (puidata)
  630. {
  631. hr = puidata->InitData(phandlerdata);
  632. if (SUCCEEDED(hr))
  633. {
  634. hr = _uilListView.AddItem(puidata);
  635. }
  636. if (FAILED(hr))
  637. {
  638. delete puidata;
  639. }
  640. }
  641. else
  642. {
  643. hr = E_OUTOFMEMORY;
  644. }
  645. phandlerdata->Release();
  646. }
  647. }
  648. }
  649. return hr;
  650. }
  651. HRESULT CNoContentDlg::_InitStatics()
  652. {
  653. if (_hiconTop)
  654. {
  655. DestroyIcon(_hiconTop);
  656. }
  657. // Set device icon
  658. _hiconTop = _GetIconFromIconLocation(_data._pszIconLocation, TRUE);
  659. SendDlgItemMessage(_hwnd, IDC_AP_MXCT_TOPICON, STM_SETIMAGE,
  660. IMAGE_ICON, (LPARAM)_hiconTop);
  661. // Set device name
  662. SetWindowText(_hwnd, _data._pszIconLabel);
  663. return S_OK;
  664. }
  665. HRESULT CNoContentDlg::_InitSelections()
  666. {
  667. HRESULT hr;
  668. if (_data._pszHandlerDefaultOriginal && *(_data._pszHandlerDefaultOriginal))
  669. {
  670. hr = _uilListView.SelectItem(_data._pszHandlerDefaultOriginal);
  671. }
  672. else
  673. {
  674. hr = _uilListView.SelectFirstItem();
  675. }
  676. if (SUCCEEDED(hr))
  677. {
  678. CHandlerData* phandlerdata;
  679. hr = _uilListView.GetSelectedItemData(&phandlerdata);
  680. if (SUCCEEDED(hr))
  681. {
  682. lstrcpyn(_szHandler, phandlerdata->_pszHandler,
  683. ARRAYSIZE(_szHandler));
  684. _SetHandlerDefault(&(_data._pszHandlerDefault), phandlerdata->_pszHandler);
  685. phandlerdata->Release();
  686. }
  687. }
  688. Button_SetCheck(GetDlgItem(_hwnd, IDC_AP_MXCT_CHECKBOX), _fCheckAlwaysDoThis);
  689. return hr;
  690. }
  691. HRESULT CNoContentDlg::_UpdateHandlerSettings()
  692. {
  693. CHandlerData* phandlerdata;
  694. HRESULT hr = _uilListView.GetSelectedItemData(&phandlerdata);
  695. if (SUCCEEDED(hr))
  696. {
  697. _SetHandlerDefault(&(_data._pszHandlerDefault), phandlerdata->_pszHandler);
  698. phandlerdata->Release();
  699. }
  700. return hr;
  701. }
  702. HRESULT CNoContentDlg::_OnListSelChange()
  703. {
  704. return _UpdateHandlerSettings();
  705. }
  706. LRESULT CNoContentDlg::OnOK(WORD wNotif)
  707. {
  708. if (BST_CHECKED == Button_GetCheck(GetDlgItem(_hwnd, IDC_AP_MXCT_CHECKBOX)))
  709. {
  710. _SaveSettings(FALSE);
  711. // return value????
  712. }
  713. else
  714. {
  715. _SaveSettings(TRUE);
  716. }
  717. _SetHandler();
  718. // Do default processing
  719. return CBaseContentDlg::OnOK(wNotif);
  720. }
  721. HRESULT CNoContentDlg::_SaveSettings(BOOL fSoftCommit)
  722. {
  723. _data._fSoftCommit = fSoftCommit;
  724. return _dlmanager.Commit();
  725. }