Leaked source code of windows server 2003
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.

757 lines
20 KiB

  1. /**********************************************************************/
  2. /** Microsoft Windows/NT **/
  3. /** Copyright(c) Microsoft Corp., 1997 **/
  4. /**********************************************************************/
  5. /*
  6. sfmfasoc.cpp
  7. Implementation for the file association property page.
  8. FILE HISTORY:
  9. 8/20/97 ericdav Code moved into file managemnet snapin
  10. */
  11. #include "stdafx.h"
  12. #include "sfmcfg.h"
  13. #include "sfmfasoc.h"
  14. #include "sfmtypes.h"
  15. #include "sfmutil.h"
  16. #ifdef _DEBUG
  17. #define new DEBUG_NEW
  18. #undef THIS_FILE
  19. static char THIS_FILE[] = __FILE__;
  20. #endif
  21. int CompareCreators(CAfpTypeCreator * pAfpTC1, CAfpTypeCreator * pAfpTC2)
  22. {
  23. CString str1, str2;
  24. str1 = pAfpTC1->QueryCreator();
  25. str2 = pAfpTC2->QueryCreator();
  26. return lstrcmpi(str1,str2);
  27. }
  28. int CompareTypes(CAfpTypeCreator * pAfpTC1, CAfpTypeCreator * pAfpTC2)
  29. {
  30. CString str1, str2;
  31. str1 = pAfpTC1->QueryType();
  32. str2 = pAfpTC2->QueryType();
  33. return lstrcmpi(str1,str2);
  34. }
  35. int CALLBACK CompareFunc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort)
  36. {
  37. CAfpTypeCreator * pAfpTC1 = (CAfpTypeCreator *) lParam1;
  38. CAfpTypeCreator * pAfpTC2 = (CAfpTypeCreator *) lParam2;
  39. CString str1, str2;
  40. int nCompare = 0;
  41. // special case, we want the default to show up at the top always
  42. if (pAfpTC1->QueryId() == AFP_DEF_TCID)
  43. return -1;
  44. else if (pAfpTC2->QueryId() == AFP_DEF_TCID)
  45. return 1;
  46. switch (lParamSort)
  47. {
  48. // creator
  49. case 0:
  50. nCompare = CompareCreators(pAfpTC1, pAfpTC2);
  51. if (nCompare == 0)
  52. nCompare = CompareTypes(pAfpTC1, pAfpTC2);
  53. break;
  54. // type
  55. case 1:
  56. nCompare = CompareTypes(pAfpTC1, pAfpTC2);
  57. if (nCompare == 0)
  58. nCompare = CompareCreators(pAfpTC1, pAfpTC2);
  59. break;
  60. // description
  61. case 2:
  62. str1 = pAfpTC1->QueryComment();
  63. str2 = pAfpTC2->QueryComment();
  64. nCompare = lstrcmpi(str1,str2);
  65. break;
  66. }
  67. return nCompare;
  68. }
  69. /////////////////////////////////////////////////////////////////////////////
  70. // CMacFilesFileAssociation property page
  71. IMPLEMENT_DYNCREATE(CMacFilesFileAssociation, CPropertyPage)
  72. CMacFilesFileAssociation::CMacFilesFileAssociation() : CPropertyPage(CMacFilesFileAssociation::IDD)
  73. {
  74. //{{AFX_DATA_INIT(CMacFilesFileAssociation)
  75. //}}AFX_DATA_INIT
  76. m_nSortColumn = 0;
  77. }
  78. CMacFilesFileAssociation::~CMacFilesFileAssociation()
  79. {
  80. }
  81. void CMacFilesFileAssociation::DoDataExchange(CDataExchange* pDX)
  82. {
  83. CPropertyPage::DoDataExchange(pDX);
  84. //{{AFX_DATA_MAP(CMacFilesFileAssociation)
  85. DDX_Control(pDX, IDC_LIST_TYPE_CREATORS, m_listctrlCreators);
  86. DDX_Control(pDX, IDC_COMBO_EXTENSION, m_comboExtension);
  87. DDX_Control(pDX, IDC_BUTTON_EDIT, m_buttonEdit);
  88. DDX_Control(pDX, IDC_BUTTON_DELETE, m_buttonDelete);
  89. DDX_Control(pDX, IDC_BUTTON_ASSOCIATE, m_buttonAssociate);
  90. DDX_Control(pDX, IDC_BUTTON_ADD, m_buttonAdd);
  91. //}}AFX_DATA_MAP
  92. }
  93. BEGIN_MESSAGE_MAP(CMacFilesFileAssociation, CPropertyPage)
  94. //{{AFX_MSG_MAP(CMacFilesFileAssociation)
  95. ON_BN_CLICKED(IDC_BUTTON_ADD, OnButtonAdd)
  96. ON_BN_CLICKED(IDC_BUTTON_ASSOCIATE, OnButtonAssociate)
  97. ON_BN_CLICKED(IDC_BUTTON_DELETE, OnButtonDelete)
  98. ON_BN_CLICKED(IDC_BUTTON_EDIT, OnButtonEdit)
  99. ON_CBN_SELCHANGE(IDC_COMBO_EXTENSION, OnSelchangeComboExtension)
  100. ON_CBN_EDITCHANGE(IDC_COMBO_EXTENSION, OnEditchangeComboExtension)
  101. ON_NOTIFY(NM_DBLCLK, IDC_LIST_TYPE_CREATORS, OnDblclkListTypeCreators)
  102. ON_WM_CLOSE()
  103. ON_WM_CONTEXTMENU()
  104. ON_WM_HELPINFO()
  105. ON_NOTIFY(LVN_ITEMCHANGED, IDC_LIST_TYPE_CREATORS, OnItemchangedListTypeCreators)
  106. ON_NOTIFY(LVN_COLUMNCLICK, IDC_LIST_TYPE_CREATORS, OnColumnclickListTypeCreators)
  107. ON_WM_DESTROY()
  108. ON_WM_COMPAREITEM()
  109. ON_WM_DRAWITEM()
  110. ON_WM_DELETEITEM()
  111. ON_NOTIFY(LVN_DELETEITEM, IDC_LIST_TYPE_CREATORS, OnDeleteitemListTypeCreators)
  112. //}}AFX_MSG_MAP
  113. END_MESSAGE_MAP()
  114. /////////////////////////////////////////////////////////////////////////////
  115. // CMacFilesFileAssociation message handlers
  116. BOOL CMacFilesFileAssociation::OnInitDialog()
  117. {
  118. CPropertyPage::OnInitDialog();
  119. m_comboExtension.LimitText(AFP_EXTENSION_LEN);
  120. InitListCtrl();
  121. //
  122. // Fill in the data from the server for extensions and type creators
  123. //
  124. Update();
  125. return TRUE; // return TRUE unless you set the focus to a control
  126. // EXCEPTION: OCX Property Pages should return FALSE
  127. }
  128. void CMacFilesFileAssociation::OnButtonAdd()
  129. {
  130. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  131. CTypeCreatorAddDlg dlgAdd(&m_listctrlCreators, m_pSheet->m_hAfpServer, m_pSheet->m_strHelpFilePath);
  132. CThemeContextActivator activator;
  133. if (dlgAdd.DoModal() == IDOK)
  134. {
  135. //
  136. // Refresh the dialog
  137. //
  138. DWORD err = Refresh();
  139. if ( err != NO_ERROR )
  140. {
  141. ::SFMMessageBox(err);
  142. return;
  143. }
  144. SelectTypeCreator(dlgAdd.m_strCreator, dlgAdd.m_strType);
  145. }
  146. }
  147. void CMacFilesFileAssociation::OnButtonEdit()
  148. {
  149. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  150. CAfpTypeCreator * pAfpTC = GetTCObject(-1); // Get current TC Object
  151. if (!pAfpTC)
  152. return;
  153. CTypeCreatorEditDlg dlgEdit(pAfpTC, m_pSheet->m_hAfpServer, m_pSheet->m_strHelpFilePath);
  154. CThemeContextActivator activator;
  155. if (dlgEdit.DoModal() == IDOK)
  156. {
  157. //
  158. // Refresh the dialog.
  159. //
  160. DWORD err = Refresh();
  161. if ( err != NO_ERROR )
  162. {
  163. ::SFMMessageBox(err);
  164. return;
  165. }
  166. }
  167. if (m_buttonEdit.GetButtonStyle() == BS_DEFPUSHBUTTON)
  168. m_buttonEdit.SetFocus();
  169. }
  170. void CMacFilesFileAssociation::OnButtonAssociate()
  171. {
  172. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  173. //
  174. // The user pressed the Associate button. So associate the currently
  175. // selected Extension with the currently selected type/creator.
  176. //
  177. AFP_TYPE_CREATOR AfpTypeCreator;
  178. AFP_EXTENSION AfpExtension;
  179. DWORD err;
  180. CString strExtension;
  181. if ( !g_SfmDLL.LoadFunctionPointers() )
  182. return;
  183. m_comboExtension.GetWindowText(strExtension);
  184. strExtension.MakeUpper();
  185. ::ZeroMemory(&AfpTypeCreator, sizeof(AfpTypeCreator));
  186. ::ZeroMemory(&AfpExtension, sizeof(AfpExtension));
  187. ::CopyMemory(AfpExtension.afpe_extension, (LPCTSTR) strExtension, strExtension.GetLength() * sizeof(TCHAR));
  188. CAfpTypeCreator * pAfpTC = GetTCObject(-1); // Get Current TC Object
  189. if (!pAfpTC)
  190. return;
  191. ::CopyMemory(AfpTypeCreator.afptc_creator, pAfpTC->QueryCreator(), pAfpTC->QueryCreatorLength() * sizeof(TCHAR));
  192. ::CopyMemory(AfpTypeCreator.afptc_type, pAfpTC->QueryType(), pAfpTC->QueryTypeLength() * sizeof(TCHAR));
  193. ::CopyMemory(AfpTypeCreator.afptc_comment, pAfpTC->QueryComment(), pAfpTC->QueryCommentLength() * sizeof(TCHAR));
  194. AfpTypeCreator.afptc_id = pAfpTC->QueryId();
  195. err = ((ETCMAPASSOCIATEPROC) g_SfmDLL[AFP_ETC_MAP_ASSOCIATE])(m_pSheet->m_hAfpServer,
  196. &AfpTypeCreator,
  197. &AfpExtension );
  198. if ( err != NO_ERROR )
  199. {
  200. ::SFMMessageBox(err);
  201. }
  202. //
  203. // Refresh the dialog
  204. //
  205. err = Refresh();
  206. if ( err != NO_ERROR )
  207. {
  208. ::SFMMessageBox(err);
  209. }
  210. }
  211. void CMacFilesFileAssociation::OnButtonDelete()
  212. {
  213. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  214. //
  215. // The user pressed the Delete button. Delete the currently
  216. // selected type/creator pair
  217. //
  218. AFP_TYPE_CREATOR AfpTypeCreator;
  219. CAfpTypeCreator * pAfpTC = GetTCObject(-1); // Get Current TC Object
  220. if (!pAfpTC)
  221. return;
  222. DWORD err;
  223. if ( !g_SfmDLL.LoadFunctionPointers() )
  224. return;
  225. //
  226. // First warn the user.
  227. //
  228. if (::AfxMessageBox(IDS_DELETE_TC_CONFIRM,
  229. MB_ICONEXCLAMATION | MB_YESNO) == IDNO )
  230. {
  231. return;
  232. }
  233. ::ZeroMemory( &AfpTypeCreator, sizeof(AfpTypeCreator) );
  234. CopyMemory(AfpTypeCreator.afptc_creator,
  235. pAfpTC->QueryCreator(),
  236. pAfpTC->QueryCreatorLength() * sizeof(TCHAR));
  237. CopyMemory(AfpTypeCreator.afptc_type,
  238. pAfpTC->QueryType(),
  239. pAfpTC->QueryTypeLength() * sizeof(TCHAR));
  240. err = ((ETCMAPDELETEPROC) g_SfmDLL[AFP_ETC_MAP_DELETE])(m_pSheet->m_hAfpServer, &AfpTypeCreator);
  241. if ( err != NO_ERROR )
  242. {
  243. ::SFMMessageBox(err);
  244. }
  245. //
  246. // Refresh the dialog.
  247. //
  248. err = Refresh();
  249. if ( err != NO_ERROR )
  250. {
  251. ::SFMMessageBox(err);
  252. return;
  253. }
  254. if ((m_buttonDelete.GetButtonStyle() == BS_DEFPUSHBUTTON) ||
  255. (m_buttonEdit.GetButtonStyle() == BS_DEFPUSHBUTTON))
  256. {
  257. //
  258. // The delete button has focus so we need to move
  259. // the focus elsewhere because this button will be
  260. // disabled. Let's set it to the add button.
  261. //
  262. m_buttonAdd.SetFocus();
  263. m_buttonAdd.SetButtonStyle(BS_DEFPUSHBUTTON);
  264. m_buttonDelete.SetButtonStyle(BS_PUSHBUTTON);
  265. m_buttonEdit.SetButtonStyle(BS_PUSHBUTTON);
  266. }
  267. }
  268. void CMacFilesFileAssociation::OnSelchangeComboExtension()
  269. {
  270. int nCurIndex = m_comboExtension.GetCurSel();
  271. if (nCurIndex != -1)
  272. {
  273. //
  274. // Select the matching type creator (if exists) and enable associate button
  275. //
  276. SelectTypeCreator((DWORD)m_comboExtension.GetItemData(nCurIndex));
  277. m_buttonAssociate.EnableWindow(TRUE);
  278. }
  279. else
  280. {
  281. m_buttonAssociate.EnableWindow(FALSE);
  282. }
  283. }
  284. void CMacFilesFileAssociation::OnEditchangeComboExtension()
  285. {
  286. CString strCurText;
  287. m_comboExtension.GetWindowText(strCurText);
  288. strCurText.MakeUpper();
  289. if (strCurText.IsEmpty())
  290. {
  291. //
  292. // User cleared out the edit box, go to the default type creator
  293. //
  294. m_buttonAssociate.EnableWindow(FALSE);
  295. SelectTypeCreator(AFP_DEF_TCID);
  296. }
  297. else
  298. {
  299. int nIndexFound = m_comboExtension.FindStringExact(-1, strCurText);
  300. if (nIndexFound != CB_ERR)
  301. {
  302. //
  303. // See if what the user has typed matches an extension in the listbox.
  304. // Set the item to be the current one.
  305. //
  306. SelectTypeCreator((DWORD)m_comboExtension.GetItemData(nIndexFound));
  307. }
  308. m_buttonAssociate.EnableWindow(TRUE);
  309. }
  310. }
  311. void CMacFilesFileAssociation::OnDblclkListTypeCreators(NMHDR* /*pNMHDR*/, LRESULT* pResult)
  312. {
  313. CAfpTypeCreator * pAfpTC = GetTCObject(-1); // Get Current TC Object
  314. //
  315. // Do not allow editing of the default type/creator
  316. //
  317. if (pAfpTC && pAfpTC->QueryId() != AFP_DEF_TCID)
  318. OnButtonEdit();
  319. *pResult = 0;
  320. }
  321. /////////////////////////////////////////////////////////////////////////////
  322. // CMacFilesFileAssociation helper functions
  323. void CMacFilesFileAssociation::EnableControls(BOOL fEnable)
  324. {
  325. if (fEnable)
  326. {
  327. m_buttonDelete.EnableWindow(TRUE);
  328. m_buttonEdit.EnableWindow(TRUE);
  329. }
  330. else
  331. {
  332. if ( (m_buttonEdit.GetState() & 0x0008) ||
  333. (m_buttonDelete.GetState() & 0x0008) )
  334. {
  335. //m_listctrlCreators.SetFocus();
  336. }
  337. m_buttonDelete.EnableWindow(FALSE);
  338. m_buttonEdit.EnableWindow(FALSE);
  339. }
  340. }
  341. DWORD CMacFilesFileAssociation::SelectTypeCreator(DWORD dwId)
  342. {
  343. DWORD dwIdSelected = (DWORD)-1;
  344. //
  345. // Find the corresponding type creator if there is one
  346. // and select it
  347. //
  348. for (int i = 0; i < m_listctrlCreators.GetItemCount(); i++)
  349. {
  350. CAfpTypeCreator * pAfpTC = GetTCObject(i); // Get TC object associated with this item
  351. if (pAfpTC && pAfpTC->QueryId() == dwId)
  352. {
  353. SetCurSel(i);
  354. dwIdSelected = pAfpTC->QueryId();
  355. break;
  356. }
  357. }
  358. if (dwIdSelected == AFP_DEF_TCID || dwIdSelected == (DWORD)-1)
  359. EnableControls(FALSE);
  360. else
  361. EnableControls(TRUE);
  362. return dwIdSelected;
  363. }
  364. DWORD CMacFilesFileAssociation::SelectTypeCreator(CString & strCreator, CString & strType)
  365. {
  366. DWORD dwIdSelected = (DWORD)-1;
  367. //
  368. // Find the corresponding type creator if there is one
  369. // and select it
  370. //
  371. for (int i = 0; i < m_listctrlCreators.GetItemCount(); i++)
  372. {
  373. CAfpTypeCreator * pAfpTC = GetTCObject(i); // Get TC object associated with this item
  374. if ( pAfpTC &&
  375. (lstrcmp(strCreator, pAfpTC->QueryCreator()) == 0) &&
  376. (lstrcmp(strType, pAfpTC->QueryType()) == 0) )
  377. {
  378. SetCurSel(i);
  379. dwIdSelected = pAfpTC->QueryId();
  380. break;
  381. }
  382. }
  383. if (dwIdSelected == AFP_DEF_TCID || dwIdSelected == (DWORD)-1)
  384. EnableControls(FALSE);
  385. else
  386. EnableControls(TRUE);
  387. return dwIdSelected;
  388. }
  389. DWORD CMacFilesFileAssociation::Update()
  390. {
  391. PAFP_ETCMAP_INFO pAfpEtcMapInfo = NULL;
  392. DWORD err;
  393. if ( !g_SfmDLL.LoadFunctionPointers() )
  394. return S_OK;
  395. //
  396. // Get the new data
  397. //
  398. err = ((ETCMAPGETINFOPROC) g_SfmDLL[AFP_ETC_MAP_GET_INFO])(m_pSheet->m_hAfpServer,
  399. (LPBYTE *)&pAfpEtcMapInfo);
  400. if ( err != NO_ERROR )
  401. {
  402. //
  403. // Couldn't get the info...
  404. //
  405. return err;
  406. }
  407. //
  408. // Update the extensions COMBOBOX.
  409. //
  410. m_comboExtension.ResetContent();
  411. PAFP_EXTENSION pAfpExtensions = pAfpEtcMapInfo->afpetc_extension;
  412. for (UINT i = 0; i < pAfpEtcMapInfo->afpetc_num_extensions; i++)
  413. {
  414. int nIndex = m_comboExtension.AddString(pAfpExtensions->afpe_extension);
  415. m_comboExtension.SetItemData(nIndex, pAfpExtensions->afpe_tcid);
  416. pAfpExtensions++;
  417. }
  418. m_comboExtension.SetCurSel(-1);
  419. m_buttonAssociate.EnableWindow(FALSE);
  420. //
  421. // Update the type/creator listbox
  422. //
  423. //
  424. // let's nuke everything in the listbox.
  425. //
  426. ClearListCtrl();
  427. PAFP_TYPE_CREATOR pAfpTypeCreators = pAfpEtcMapInfo->afpetc_type_creator;
  428. for (i = 0; i < pAfpEtcMapInfo->afpetc_num_type_creators; i++)
  429. {
  430. CAfpTypeCreator * pItemData = new CAfpTypeCreator(pAfpTypeCreators);
  431. InsertItem(pItemData);
  432. pAfpTypeCreators++;
  433. }
  434. if ( pAfpEtcMapInfo != NULL )
  435. {
  436. ((SFMBUFFERFREEPROC) g_SfmDLL[AFP_BUFFER_FREE])(pAfpEtcMapInfo);
  437. }
  438. m_listctrlCreators.SortItems(CompareFunc, m_nSortColumn);
  439. //
  440. // Set the current selection to be the default type creator
  441. //
  442. SelectTypeCreator(AFP_DEF_TCID);
  443. return NO_ERROR;
  444. }
  445. void CMacFilesFileAssociation::InitListCtrl()
  446. {
  447. CString strText;
  448. strText.LoadString(IDS_CREATOR);
  449. m_listctrlCreators.InsertColumn(0, strText, LVCFMT_LEFT, 50);
  450. strText.LoadString(IDS_TYPE);
  451. m_listctrlCreators.InsertColumn(1, strText, LVCFMT_LEFT, 50);
  452. strText.LoadString(IDS_DESCRIPTION);
  453. m_listctrlCreators.InsertColumn(2, strText, LVCFMT_LEFT, 175);
  454. ListView_SetExtendedListViewStyle(m_listctrlCreators.GetSafeHwnd(), LVS_EX_FULLROWSELECT);
  455. }
  456. void CMacFilesFileAssociation::ClearListCtrl()
  457. {
  458. m_listctrlCreators.DeleteAllItems();
  459. }
  460. void CMacFilesFileAssociation::InsertItem(CAfpTypeCreator * pItemData)
  461. {
  462. int nIndex = m_listctrlCreators.InsertItem(0, pItemData->QueryCreator());
  463. m_listctrlCreators.SetItemText(nIndex, 1, pItemData->QueryType());
  464. m_listctrlCreators.SetItemText(nIndex, 2, pItemData->QueryComment());
  465. m_listctrlCreators.SetItemData(nIndex, (DWORD_PTR) pItemData);
  466. }
  467. void CMacFilesFileAssociation::SetCurSel(int nIndex)
  468. {
  469. LV_ITEM lvItem;
  470. ZeroMemory(&lvItem, sizeof(lvItem));
  471. lvItem.iItem = nIndex;
  472. lvItem.mask = LVIF_STATE;
  473. lvItem.stateMask = LVIS_SELECTED | LVIS_FOCUSED;
  474. lvItem.state = LVIS_SELECTED | LVIS_FOCUSED;
  475. m_listctrlCreators.SetItem(&lvItem);
  476. m_listctrlCreators.EnsureVisible(nIndex, FALSE);
  477. }
  478. int CMacFilesFileAssociation::GetCurSel()
  479. {
  480. return m_listctrlCreators.GetNextItem(-1, LVNI_SELECTED);
  481. }
  482. DWORD CMacFilesFileAssociation::Refresh()
  483. {
  484. //
  485. // Find out the type creator that has the current focus.
  486. //
  487. CAfpTypeCreator * pAfpTC = GetTCObject(-1); // Get Current TC Object
  488. if (!pAfpTC)
  489. return NO_ERROR;
  490. DWORD dwIdCreator = pAfpTC->QueryId();
  491. CWnd * pFocusWnd = CWnd::GetFocus();
  492. //
  493. // Find out the extension that has the current focus
  494. //
  495. DWORD err;
  496. CString strCurExtension;
  497. m_comboExtension.GetWindowText(strCurExtension);
  498. strCurExtension.MakeUpper();
  499. if ( (err = Update()) != NO_ERROR )
  500. {
  501. if (pFocusWnd)
  502. pFocusWnd->SetFocus();
  503. return err;
  504. }
  505. DWORD dwIdSelected = SelectTypeCreator(dwIdCreator);
  506. //
  507. // Set the extension to what it was before
  508. //
  509. if (strCurExtension.IsEmpty())
  510. {
  511. m_buttonAssociate.EnableWindow(FALSE);
  512. }
  513. else
  514. {
  515. m_comboExtension.SetWindowText(strCurExtension);
  516. m_buttonAssociate.EnableWindow(TRUE);
  517. }
  518. if (pFocusWnd)
  519. pFocusWnd->SetFocus();
  520. return NO_ERROR;
  521. }
  522. CAfpTypeCreator * CMacFilesFileAssociation::GetTCObject(int nIndex)
  523. {
  524. if (-1 == nIndex)
  525. nIndex = GetCurSel();
  526. if (-1 == nIndex)
  527. return NULL;
  528. return (CAfpTypeCreator *) m_listctrlCreators.GetItemData(nIndex);
  529. }
  530. void CMacFilesFileAssociation::OnClose()
  531. {
  532. ClearListCtrl();
  533. m_comboExtension.ResetContent();
  534. CPropertyPage::OnClose();
  535. }
  536. BOOL CMacFilesFileAssociation::OnHelpInfo(HELPINFO* pHelpInfo)
  537. {
  538. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  539. if (pHelpInfo->iContextType == HELPINFO_WINDOW)
  540. {
  541. ::WinHelp ((HWND)pHelpInfo->hItemHandle,
  542. m_pSheet->m_strHelpFilePath,
  543. HELP_WM_HELP,
  544. g_aHelpIDs_CONFIGURE_SFM);
  545. }
  546. return TRUE;
  547. }
  548. void CMacFilesFileAssociation::OnContextMenu(CWnd* pWnd, CPoint /*point*/)
  549. {
  550. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  551. if (this == pWnd)
  552. return;
  553. ::WinHelp (pWnd->m_hWnd,
  554. m_pSheet->m_strHelpFilePath,
  555. HELP_CONTEXTMENU,
  556. g_aHelpIDs_CONFIGURE_SFM);
  557. }
  558. void CMacFilesFileAssociation::OnItemchangedListTypeCreators(NMHDR* pNMHDR, LRESULT* pResult)
  559. {
  560. NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR;
  561. //
  562. // Get the selected item's data which points to a TypeCreator object.
  563. // Check the ID of that object to see how we should enable the buttons.
  564. //
  565. if (pNMListView->uNewState & LVIS_SELECTED)
  566. {
  567. CAfpTypeCreator * pAfpTC = GetTCObject(-1); // Get Current TC Object
  568. if (pAfpTC)
  569. {
  570. DWORD dwId = pAfpTC->QueryId();
  571. if (dwId == AFP_DEF_TCID || dwId == (DWORD)-1)
  572. EnableControls(FALSE);
  573. else
  574. EnableControls(TRUE);
  575. }
  576. }
  577. *pResult = 0;
  578. }
  579. void CMacFilesFileAssociation::OnColumnclickListTypeCreators(NMHDR* pNMHDR, LRESULT* pResult)
  580. {
  581. NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR;
  582. m_nSortColumn = pNMListView->iSubItem;
  583. m_listctrlCreators.SortItems(CompareFunc, m_nSortColumn);
  584. *pResult = 0;
  585. }
  586. void CMacFilesFileAssociation::OnDestroy()
  587. {
  588. CPropertyPage::OnDestroy();
  589. ClearListCtrl();
  590. m_comboExtension.ResetContent();
  591. }
  592. void CMacFilesFileAssociation::OnDeleteitemListTypeCreators(NMHDR* pNMHDR, LRESULT* pResult)
  593. {
  594. NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR;
  595. delete (CAfpTypeCreator *) pNMListView->lParam;
  596. *pResult = 0;
  597. }