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.

768 lines
20 KiB

  1. //+-------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1994 - 1999
  5. //
  6. // File: DragDropTest.cxx
  7. //
  8. // Contents: Classes that implement Drag & Drop tests using the framework.
  9. //
  10. //--------------------------------------------------------------------
  11. #include "stdafx.hxx"
  12. int CDragDropSnapinRootItem::s_iNextChildID = 0;
  13. //+-------------------------------------------------------------------
  14. //
  15. // Member: CDragDropSnapinRootItem::ScInit
  16. //
  17. // Synopsis: Called immeadiately after the item is created to init
  18. // displayname, icon index etc...
  19. //
  20. // Arguments: [CBaseSnapin] -
  21. // [CColumnInfoEx] - Any columns to be displayed for this item.
  22. // [INT] - # of columns
  23. //
  24. // Returns: SC
  25. //
  26. //--------------------------------------------------------------------
  27. SC CDragDropSnapinRootItem::ScInit(CBaseSnapin *pSnapin, CColumnInfoEx *pcolinfoex, INT ccolinfoex, BOOL fIsRoot)
  28. {
  29. DECLARE_SC(sc, _T("CDragDropSnapinRootItem::ScInit"));
  30. sc = CBaseSnapinItem::ScInit(pSnapin, pcolinfoex, ccolinfoex, fIsRoot);
  31. if (sc)
  32. return sc;
  33. // Init following
  34. // a. Icon index.
  35. // b. Load display name.
  36. m_uIconIndex = 3; // use an enum instead of 3
  37. m_strDisplayName.LoadString(_Module.GetResourceInstance(), IDS_DragDropRoot);
  38. tstring strItem;
  39. strItem.LoadString(_Module.GetResourceInstance(), IDS_DragDropScopeItem);
  40. int cChildren = 4; // child nodes.
  41. WTL::CString strTemp;
  42. for (int i = 0; i < cChildren; ++i)
  43. {
  44. strTemp.Format(_T("%s - %d"), strItem.data(), i);
  45. m_vecContainerItems.push_back((LPCTSTR)strTemp);
  46. }
  47. return sc;
  48. }
  49. //+-------------------------------------------------------------------
  50. //
  51. // Member: CDragDropSnapinRootItem::ScGetField
  52. //
  53. // Synopsis: Get the string representation for given field to display
  54. // it in result pane.
  55. //
  56. // Arguments: [DAT] - The column requested (this is an enumeration).
  57. // [tstring] - Out string.
  58. //
  59. // Returns: SC
  60. //
  61. //--------------------------------------------------------------------
  62. SC CDragDropSnapinRootItem::ScGetField (DAT dat, tstring& strField)
  63. {
  64. DECLARE_SC(sc, _T("CDragDropSnapinRootItem::ScGetField"));
  65. switch(dat)
  66. {
  67. case datString1:
  68. strField = m_strDisplayName;
  69. break;
  70. case datString2:
  71. strField = _T("Root String2");
  72. break;
  73. case datString3:
  74. strField = _T("Root String3");
  75. break;
  76. default:
  77. E_INVALIDARG;
  78. break;
  79. }
  80. return (sc);
  81. }
  82. //+-------------------------------------------------------------------
  83. //
  84. // Member: CDragDropSnapinRootItem::ScCreateChildren
  85. //
  86. // Synopsis: Create any children (nodes & leaf items) for this item.
  87. //
  88. // Arguments: None
  89. //
  90. // Returns: SC
  91. //
  92. //--------------------------------------------------------------------
  93. SC CDragDropSnapinRootItem::ScCreateChildren ()
  94. {
  95. DECLARE_SC(sc, _T("CDragDropSnapinRootItem::ScCreateChildren"));
  96. CDragDropSnapinLVContainer * pitemChild = NULL;
  97. CDragDropSnapinLVContainer * pitemPrevious = NULL;
  98. // Let us create child items for this container.
  99. StringVector::iterator itItem;
  100. // Create scope items for this container.
  101. for (itItem = m_vecContainerItems.begin(); itItem != m_vecContainerItems.end(); ++itItem, ++s_iNextChildID )
  102. {
  103. // Create the child nodes and init them.
  104. sc = CDragDropSnapinLVContainer::ScCreateLVContainer(this, pitemPrevious, &pitemChild, FALSE); // Why FALSE???
  105. if (sc)
  106. return sc;
  107. pitemPrevious = pitemChild;
  108. pitemChild->SetDisplayName(*itItem);
  109. }
  110. return (sc);
  111. }
  112. SC CDragDropSnapinRootItem::ScInitializeChild(CBaseSnapinItem* pitem)
  113. {
  114. CDragDropSnapinLVContainer *pDDItem = dynamic_cast<CDragDropSnapinLVContainer*>(pitem);
  115. if (pDDItem)
  116. pDDItem->SetDisplayIndex(s_iNextChildID);
  117. return CBaseSnapinItem::ScInitializeChild(pitem);
  118. }
  119. // Initialize context menu structures. Let us have one item for demonstration.
  120. SnapinMenuItem CDragDropSnapinRootItem::s_rgmenuitemRoot[] =
  121. {
  122. {IDS_EnablePasteInToResultItem, IDS_EnablePasteInToResultItem, IDS_EnablePasteInToResultItem, CCM_INSERTIONPOINTID_PRIMARY_TOP, NULL, dwMenuAlwaysEnable, dwMenuNeverGray, 0},
  123. {IDS_DisableCut, IDS_DisableCut, IDS_DisableCut, CCM_INSERTIONPOINTID_PRIMARY_TOP, NULL, dwMenuAlwaysEnable, dwMenuNeverGray, 0},
  124. };
  125. INT CDragDropSnapinRootItem::s_cmenuitemRoot = CMENUITEM(s_rgmenuitemRoot);
  126. // -----------------------------------------------------------------------------
  127. SnapinMenuItem *CDragDropSnapinRootItem::Pmenuitem(void)
  128. {
  129. return s_rgmenuitemRoot;
  130. }
  131. // -----------------------------------------------------------------------------
  132. INT CDragDropSnapinRootItem::CMenuItem(void)
  133. {
  134. return s_cmenuitemRoot;
  135. }
  136. //+-------------------------------------------------------------------
  137. //
  138. // Member: CDragDropSnapinRootItem::ScCommand
  139. //
  140. // Synopsis:
  141. //
  142. // Arguments:
  143. //
  144. // Returns: SC
  145. //
  146. //--------------------------------------------------------------------
  147. SC CDragDropSnapinRootItem::ScCommand (long nCommandID, CComponent *pComponent)
  148. {
  149. DECLARE_SC(sc, _T("CDragDropSnapinRootItem::ScCommand"));
  150. CDragDropSnapin *pDragDropSnapin = dynamic_cast<CDragDropSnapin*>(Psnapin());
  151. if (!pDragDropSnapin)
  152. return sc;
  153. switch(nCommandID)
  154. {
  155. case IDS_EnablePasteInToResultItem:
  156. {
  157. BOOL bEnabled = pDragDropSnapin->FPasteIntoResultPane();
  158. pDragDropSnapin->SetPasteIntoResultPane(!bEnabled);
  159. for (int i = 0; i < CMenuItem(); ++i)
  160. {
  161. if (s_rgmenuitemRoot[i].lCommandID == IDS_EnablePasteInToResultItem)
  162. s_rgmenuitemRoot[i].dwFlagsChecked = (!bEnabled);
  163. }
  164. }
  165. break;
  166. case IDS_DisableCut:
  167. {
  168. BOOL bDisabled = pDragDropSnapin->FCutDisabled();
  169. pDragDropSnapin->SetCutDisabled(! bDisabled);
  170. for (int i = 0; i < CMenuItem(); ++i)
  171. {
  172. if (s_rgmenuitemRoot[i].lCommandID == IDS_DisableCut)
  173. s_rgmenuitemRoot[i].dwFlagsChecked = (!bDisabled);
  174. }
  175. }
  176. break;
  177. default:
  178. sc = E_INVALIDARG;
  179. break;
  180. }
  181. return (sc);
  182. }
  183. //+-------------------------------------------------------------------
  184. //
  185. // Member: CDragDropSnapinLVContainer::ScInit
  186. //
  187. // Synopsis: Called immeadiately after the item is created to init
  188. // displayname, icon index etc...
  189. //
  190. // Arguments: [CBaseSnapin] -
  191. // [CColumnInfoEx] - Any columns to be displayed for this item.
  192. // [INT] - # of columns
  193. //
  194. // Returns: SC
  195. //
  196. //--------------------------------------------------------------------
  197. SC CDragDropSnapinLVContainer::ScInit(CBaseSnapin *pSnapin, CColumnInfoEx *pcolinfoex, INT ccolinfoex, BOOL fIsRoot)
  198. {
  199. DECLARE_SC(sc, _T("CDragDropSnapinLVContainer::ScInit"));
  200. sc = CBaseSnapinItem::ScInit(pSnapin, pcolinfoex, ccolinfoex, fIsRoot);
  201. if (sc)
  202. return sc;
  203. // Init following
  204. // a. Icon index.
  205. // b. Load display name.
  206. m_uIconIndex = 4; // use an enum instead of 4
  207. m_strDisplayName = _T("None");
  208. tstring strLeafItem;
  209. strLeafItem.LoadString(_Module.GetResourceInstance(), IDS_DragDropResultItem);
  210. int cLeafItems = 4;
  211. WTL::CString strTemp;
  212. for (int i = 0; i < cLeafItems; ++i)
  213. {
  214. strTemp.Format(_T("%s - [%d : %d]"), strLeafItem.data(), m_index, i);
  215. m_vecLeafItems.push_back((LPCTSTR)strTemp);
  216. }
  217. return sc;
  218. }
  219. //+-------------------------------------------------------------------
  220. //
  221. // Member: CDragDropSnapinLVContainer::ScGetField
  222. //
  223. // Synopsis: Get the string representation for given field to display
  224. // it in result pane.
  225. //
  226. // Arguments: [DAT] - The column requested (this is an enumeration).
  227. // [tstring] - Out string.
  228. //
  229. // Returns: SC
  230. //
  231. //--------------------------------------------------------------------
  232. SC CDragDropSnapinLVContainer::ScGetField (DAT dat, tstring& strField)
  233. {
  234. DECLARE_SC(sc, _T("CDragDropSnapinLVContainer::ScGetField"));
  235. switch(dat)
  236. {
  237. case datString1:
  238. strField = m_strDisplayName;
  239. break;
  240. case datString2:
  241. strField = _T("None");
  242. break;
  243. default:
  244. E_INVALIDARG;
  245. break;
  246. }
  247. return (sc);
  248. }
  249. //+-------------------------------------------------------------------
  250. //
  251. // Member: CDragDropSnapinLVContainer::ScCreateChildren
  252. //
  253. // Synopsis: Create any children (nodes & leaf items) for this item.
  254. //
  255. // Arguments: None
  256. //
  257. // Returns: SC
  258. //
  259. //--------------------------------------------------------------------
  260. SC CDragDropSnapinLVContainer::ScCreateChildren ()
  261. {
  262. DECLARE_SC(sc, _T("CDragDropSnapinLVContainer::ScCreateChildren"));
  263. CDragDropSnapinLVContainer* pitem = NULL;
  264. CDragDropSnapinLVLeafItem * pitemChild = NULL;
  265. CBaseSnapinItem * pitemPrevious = NULL;
  266. StringVector::iterator itItem;
  267. int index = 0;
  268. // Create scope items for this container.
  269. for (itItem = m_vecContainerItems.begin(); itItem != m_vecContainerItems.end(); ++itItem, ++index )
  270. {
  271. // Create the child nodes and init them.
  272. sc = CDragDropSnapinLVContainer::ScCreateLVContainer(this, NULL, &pitem, FALSE); // Why FALSE???
  273. if (sc)
  274. return sc;
  275. pitem->SetDisplayName(*itItem);
  276. pitem->SetDisplayIndex(index);
  277. pitemPrevious = pitem;
  278. }
  279. // Create leaf items for this container.
  280. for (itItem = m_vecLeafItems.begin(); itItem != m_vecLeafItems.end(); ++itItem )
  281. {
  282. // Create the child nodes and init them.
  283. sc = CDragDropSnapinLVLeafItem::ScCreateLVLeafItem(this, pitemPrevious, &pitemChild, FALSE); // Why FALSE???
  284. if (sc)
  285. return sc;
  286. pitemChild->SetDisplayName(*itItem );
  287. pitemPrevious = pitemChild;
  288. }
  289. return (sc);
  290. }
  291. //+-------------------------------------------------------------------
  292. //
  293. // Member: CDragDropSnapinLVContainer::ScCreateLVContainer
  294. //
  295. // Synopsis: Do we really need this method?
  296. //
  297. // Arguments:
  298. //
  299. // Returns: SC
  300. //
  301. //--------------------------------------------------------------------
  302. SC CDragDropSnapinLVContainer::ScCreateLVContainer(CBaseSnapinItem *pitemParent, CBaseSnapinItem *pitemPrevious, CDragDropSnapinLVContainer ** ppitem, BOOL fNew)
  303. {
  304. DECLARE_SC(sc, _T("CDragDropSnapinRootItem::ScCreateLVContainer"));
  305. t_item * pitem = NULL;
  306. *ppitem = NULL;
  307. // What to do here?
  308. sc = ::ScCreateItem(pitemParent, pitemPrevious, &pitem, fNew);
  309. if (sc)
  310. return sc;
  311. *ppitem = pitem;
  312. return (sc);
  313. }
  314. SC CDragDropSnapinLVContainer::ScOnSelect(CComponent * pComponent, LPDATAOBJECT lpDataObject, BOOL fScope, BOOL fSelect)
  315. {
  316. DECLARE_SC(sc, TEXT("CDragDropSnapinLVContainer::ScOnSelect"));
  317. sc = ScCheckPointers(pComponent);
  318. if (sc)
  319. return sc;
  320. CDragDropSnapin *pDragDropSnapin = dynamic_cast<CDragDropSnapin*>(Psnapin());
  321. if (!pDragDropSnapin)
  322. return S_OK;
  323. IConsoleVerb *pConsoleVerb = pComponent->IpConsoleVerb();
  324. sc = pConsoleVerb ? pConsoleVerb->SetVerbState(MMC_VERB_CUT, ENABLED, !pDragDropSnapin->FCutDisabled()) : E_UNEXPECTED;
  325. return (sc);
  326. }
  327. SC CDragDropSnapinLVContainer::ScOnQueryPaste(LPDATAOBJECT pDataObject, BOOL *pfCanPaste)
  328. {
  329. DECLARE_SC(sc, _T("CDragDropSnapinLVContainer::ScOnQueryPaste"));
  330. sc = ScCheckPointers(pDataObject, pfCanPaste);
  331. if (sc)
  332. return sc;
  333. *pfCanPaste = FALSE;
  334. CLSID guidNodeType;
  335. sc = ScGetNodeType(pDataObject, &guidNodeType);
  336. if (sc)
  337. return sc;
  338. if (IsEqualGUID(guidNodeType, clsidNodeTypeDragDropLVContainer) ||
  339. IsEqualGUID(guidNodeType, clsidNodeTypeDragDropLVLeafItem) )
  340. {
  341. *pfCanPaste = TRUE;
  342. return (sc = S_OK);
  343. }
  344. return (sc = S_FALSE);
  345. }
  346. SC CDragDropSnapinLVContainer::ScOnPaste(LPDATAOBJECT pDataObject, BOOL fMove, BOOL *pfPasted)
  347. {
  348. DECLARE_SC(sc, TEXT("CDragDropSnapinLVContainer::ScOnPaste"));
  349. sc = ScCheckPointers(pDataObject, pfPasted);
  350. if (sc)
  351. return sc;
  352. *pfPasted = FALSE;
  353. CLSID guidNodeType;
  354. sc = ScGetNodeType(pDataObject, &guidNodeType);
  355. if (sc)
  356. return sc;
  357. tstring strDispName;
  358. sc = ScGetDisplayName(pDataObject, strDispName);
  359. if (sc)
  360. return sc;
  361. if (IsEqualGUID(guidNodeType, clsidNodeTypeDragDropLVContainer) )
  362. {
  363. m_vecContainerItems.push_back(strDispName);
  364. }
  365. else if (IsEqualGUID(guidNodeType, clsidNodeTypeDragDropLVLeafItem) )
  366. {
  367. m_vecLeafItems.push_back(strDispName);
  368. }
  369. else
  370. return (sc = S_FALSE);
  371. *pfPasted = TRUE;
  372. return sc;
  373. }
  374. BOOL CDragDropSnapinLVContainer::FAllowPasteForResultItems()
  375. {
  376. CDragDropSnapin *pDragDropSnapin = dynamic_cast<CDragDropSnapin*>(Psnapin());
  377. if (!pDragDropSnapin)
  378. return FALSE;
  379. return pDragDropSnapin->FPasteIntoResultPane();
  380. }
  381. SC CDragDropSnapinLVContainer::ScOnCutOrMove()
  382. {
  383. DECLARE_SC(sc, TEXT("CDragDropSnapinLVContainer::ScOnCutOrMove"));
  384. LPDATAOBJECT pDataObject = dynamic_cast<LPDATAOBJECT>(this);
  385. sc = ScCheckPointers(pDataObject, E_UNEXPECTED);
  386. if (sc)
  387. return sc;
  388. tstring strDispName;
  389. sc = ScGetDisplayName(pDataObject, strDispName);
  390. if (sc)
  391. return sc;
  392. CDragDropSnapinLVContainer *pitemParent = dynamic_cast<CDragDropSnapinLVContainer*>(PitemParent());
  393. sc = ScCheckPointers(pitemParent, E_UNEXPECTED);
  394. if (! sc.IsError())
  395. {
  396. sc = pitemParent->_ScDeleteCutItem(strDispName, true);
  397. return sc;
  398. }
  399. CDragDropSnapinRootItem *pRootitem= dynamic_cast<CDragDropSnapinRootItem*>(PitemParent());
  400. sc = ScCheckPointers(pRootitem, E_UNEXPECTED);
  401. if (sc)
  402. return sc;
  403. sc = pRootitem->_ScDeleteCutItem(strDispName);
  404. return sc;
  405. }
  406. //+-------------------------------------------------------------------
  407. //
  408. // Member: CDragDropSnapinLVLeafItem::ScInit
  409. //
  410. // Synopsis: Called immeadiately after the item is created to init
  411. // displayname, icon index etc...
  412. //
  413. // Arguments: [CBaseSnapin] -
  414. // [CColumnInfoEx] - Any columns to be displayed for this item.
  415. // [INT] - # of columns
  416. //
  417. // Returns: SC
  418. //
  419. //--------------------------------------------------------------------
  420. SC CDragDropSnapinLVLeafItem::ScInit(CBaseSnapin *pSnapin, CColumnInfoEx *pcolinfoex, INT ccolinfoex, BOOL fIsRoot)
  421. {
  422. DECLARE_SC(sc, _T("CDragDropSnapinLVLeafItem::ScInit"));
  423. sc = CBaseSnapinItem::ScInit(pSnapin, pcolinfoex, ccolinfoex, fIsRoot);
  424. if (sc)
  425. return sc;
  426. // Init following
  427. // a. Icon index.
  428. // b. Load display name.
  429. m_uIconIndex = 7; // use an enum instead of 7
  430. m_strDisplayName = m_strItemPasted = _T("None");
  431. return sc;
  432. }
  433. //+-------------------------------------------------------------------
  434. //
  435. // Member: CDragDropSnapinLVLeafItem::ScGetField
  436. //
  437. // Synopsis: Get the string representation for given field to display
  438. // it in result pane.
  439. //
  440. // Arguments: [DAT] - The column requested (this is an enumeration).
  441. // [tstring] - Out string.
  442. //
  443. // Returns: SC
  444. //
  445. //--------------------------------------------------------------------
  446. SC CDragDropSnapinLVLeafItem::ScGetField (DAT dat, tstring& strField)
  447. {
  448. DECLARE_SC(sc, _T("CDragDropSnapinLVLeafItem::ScGetField"));
  449. switch(dat)
  450. {
  451. case datString1:
  452. strField = m_strDisplayName;
  453. break;
  454. case datString2:
  455. strField = m_strItemPasted;
  456. break;
  457. default:
  458. E_INVALIDARG;
  459. break;
  460. }
  461. return (sc);
  462. }
  463. //+-------------------------------------------------------------------
  464. //
  465. // Member: CDragDropSnapinLVLeafItem::ScCreateLVLeafItem
  466. //
  467. // Synopsis: Do we really need this method?
  468. //
  469. // Arguments:
  470. //
  471. // Returns: SC
  472. //
  473. //--------------------------------------------------------------------
  474. SC CDragDropSnapinLVLeafItem::ScCreateLVLeafItem(CBaseSnapinItem *pitemParent, CBaseSnapinItem * pitemPrevious, CDragDropSnapinLVLeafItem ** ppitem, BOOL fNew)
  475. {
  476. DECLARE_SC(sc, _T("CDragDropSnapinLVLeafItem::ScCreateLVLeafItem"));
  477. t_itemChild * pitem = NULL;
  478. *ppitem = NULL;
  479. // What to do here?
  480. sc = ::ScCreateItem(pitemParent, pitemPrevious, &pitem, fNew);
  481. if (sc)
  482. return sc;
  483. *ppitem = pitem;
  484. return (sc);
  485. }
  486. SC CDragDropSnapinLVLeafItem::ScOnQueryPaste(LPDATAOBJECT pDataObject, BOOL *pfCanPaste)
  487. {
  488. DECLARE_SC(sc, TEXT("CDragDropSnapinLVLeafItem::ScOnQueryPaste"));
  489. sc = ScCheckPointers(pDataObject, pfCanPaste);
  490. if (sc)
  491. return sc;
  492. *pfCanPaste = FALSE;
  493. CLSID guidNodeType;
  494. sc = ScGetNodeType(pDataObject, &guidNodeType);
  495. if (sc)
  496. return sc;
  497. if (IsEqualGUID(guidNodeType, clsidNodeTypeDragDropLVContainer) ||
  498. IsEqualGUID(guidNodeType, clsidNodeTypeDragDropLVLeafItem) )
  499. {
  500. CDragDropSnapin *pDragDropSnapin = dynamic_cast<CDragDropSnapin*>(Psnapin());
  501. if (!pDragDropSnapin)
  502. return S_OK;
  503. *pfCanPaste = pDragDropSnapin->FPasteIntoResultPane();
  504. return (sc = S_OK);
  505. }
  506. return (sc = S_FALSE);
  507. }
  508. SC CDragDropSnapinLVLeafItem::ScGetVerbs(DWORD * pdwVerbs)
  509. {
  510. *pdwVerbs = vmDelete | vmCopy | vmRename;
  511. CDragDropSnapin *pDragDropSnapin = dynamic_cast<CDragDropSnapin*>(Psnapin());
  512. if (!pDragDropSnapin)
  513. return S_OK;
  514. if (pDragDropSnapin->FPasteIntoResultPane())
  515. *pdwVerbs |= vmPaste;
  516. return S_OK;
  517. }
  518. SC CDragDropSnapinLVLeafItem::ScOnSelect(CComponent * pComponent, LPDATAOBJECT lpDataObject, BOOL fScope, BOOL fSelect)
  519. {
  520. DECLARE_SC(sc, TEXT("CDragDropSnapinLVLeafItem::ScOnSelect"));
  521. sc = ScCheckPointers(pComponent);
  522. if (sc)
  523. return sc;
  524. CDragDropSnapin *pDragDropSnapin = dynamic_cast<CDragDropSnapin*>(Psnapin());
  525. if (!pDragDropSnapin)
  526. return S_OK;
  527. IConsoleVerb *pConsoleVerb = pComponent->IpConsoleVerb();
  528. sc = pConsoleVerb ? pConsoleVerb->SetVerbState(MMC_VERB_CUT, ENABLED, !pDragDropSnapin->FCutDisabled()) : E_UNEXPECTED;
  529. return (sc);
  530. }
  531. SC CDragDropSnapinLVLeafItem::ScOnPaste(LPDATAOBJECT pDataObject, BOOL fMove, BOOL *pfPasted)
  532. {
  533. DECLARE_SC(sc, TEXT("CDragDropSnapinLVLeafItem::ScOnPaste"));
  534. sc = ScCheckPointers(pDataObject, pfPasted);
  535. *pfPasted = FALSE;
  536. CLSID guidNodeType;
  537. sc = ScGetNodeType(pDataObject, &guidNodeType);
  538. if (sc)
  539. return sc;
  540. tstring strDispName;
  541. sc = ScGetDisplayName(pDataObject, strDispName);
  542. if (sc)
  543. return sc;
  544. if (IsEqualGUID(guidNodeType, clsidNodeTypeDragDropLVContainer) ||
  545. IsEqualGUID(guidNodeType, clsidNodeTypeDragDropLVLeafItem) )
  546. {
  547. m_strItemPasted = strDispName;
  548. }
  549. else
  550. return (sc = S_FALSE);
  551. *pfPasted = TRUE;
  552. return sc;
  553. }
  554. SC CDragDropSnapinLVLeafItem::ScOnCutOrMove()
  555. {
  556. DECLARE_SC(sc, TEXT("CDragDropSnapinLVLeafItem::ScOnCutOrMove"));
  557. LPDATAOBJECT pDataObject = dynamic_cast<LPDATAOBJECT>(this);
  558. sc = ScCheckPointers(pDataObject, E_UNEXPECTED);
  559. if (sc)
  560. return sc;
  561. tstring strDispName;
  562. sc = ScGetDisplayName(pDataObject, strDispName);
  563. if (sc)
  564. return sc;
  565. CDragDropSnapinLVContainer *pitemParent = dynamic_cast<CDragDropSnapinLVContainer*>(PitemParent());
  566. sc = ScCheckPointers(pitemParent, E_UNEXPECTED);
  567. if (sc)
  568. return sc;
  569. sc = pitemParent->_ScDeleteCutItem(strDispName, false);
  570. return sc;
  571. }
  572. //-------------------------------------------------------------------------------------
  573. // class CDragDropSnapin
  574. #pragma BEGIN_CODESPACE_DATA
  575. SNR CDragDropSnapin::s_rgsnr[] =
  576. {
  577. SNR(&nodetypeDragDropRoot, snrEnumSP ), // Standalone snapin.
  578. SNR(&nodetypeDragDropLVContainer, snrEnumSP | snrEnumRP | snrPaste), // enumerates this node in the scope pane and result pane.
  579. SNR(&nodetypeDragDropLVLeafItem, snrEnumSP | snrEnumRP | snrPaste), // enumerates this node in the scope pane and result pane.
  580. };
  581. LONG CDragDropSnapin::s_rgiconid[] = {3};
  582. LONG CDragDropSnapin::s_iconidStatic = 2;
  583. CColumnInfoEx CDragDropSnapin::s_colinfo[] =
  584. {
  585. CColumnInfoEx(_T("Name"), LVCFMT_LEFT, 250, datString1),
  586. CColumnInfoEx(_T("Last Cut/Copy/Paste operation"), LVCFMT_LEFT, 180, datString2),
  587. };
  588. INT CDragDropSnapin::s_ccolinfo = sizeof(s_colinfo) / sizeof(CColumnInfoEx);
  589. INT CDragDropSnapin::s_colwidths[1];
  590. #pragma END_CODESPACE_DATA
  591. // include members needed for every snapin.
  592. SNAPIN_DEFINE( CDragDropSnapin);
  593. /* CDragDropSnapin::CDragDropSnapin
  594. *
  595. * PURPOSE: Constructor
  596. *
  597. * PARAMETERS: None
  598. *
  599. */
  600. CDragDropSnapin::CDragDropSnapin()
  601. {
  602. m_pstrDisplayName = new tstring();
  603. *m_pstrDisplayName = _T("DragDrop Snapin Root");
  604. }
  605. /* CDragDropSnapin::~CDragDropSnapin
  606. *
  607. * PURPOSE: Destructor
  608. *
  609. * PARAMETERS: None
  610. *
  611. */
  612. CDragDropSnapin::~CDragDropSnapin()
  613. {
  614. delete m_pstrDisplayName;
  615. }