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.

192 lines
6.5 KiB

  1. //+-------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1994 - 1999
  5. //
  6. // File: Component2snapin.hxx
  7. //
  8. // Contents: The snapin implements IComponentData2 & IComponent2 interfaces.
  9. // This file contains classes that implement framework methods on
  10. // CBaseSnapinItem to support these interfaces.
  11. //
  12. //--------------------------------------------------------------------
  13. #pragma once
  14. // Forward declarations.
  15. class CRenameSnapinLVLeafItem;
  16. //+-------------------------------------------------------------------
  17. //
  18. // Class: CRenameRootItem
  19. //
  20. // Purpose: Implements the root item for a standalone snapin.
  21. //
  22. //--------------------------------------------------------------------
  23. class CRenameRootItem : public CBaseSnapinItem
  24. {
  25. typedef CBaseSnapinItem super;
  26. // Used by CBaseSnapinItem::ScCreateItem, connect this item with its children.
  27. typedef CComObject<CSnapinItem<CRenameRootItem> > t_item;
  28. typedef CComObject<CSnapinItem<CRenameSnapinLVLeafItem> > t_itemChild;
  29. public:
  30. CRenameRootItem( void ) {} // Raw constructor - use only for static item.
  31. virtual ~CRenameRootItem( void ) {}
  32. BEGIN_COM_MAP(CRenameRootItem)
  33. COM_INTERFACE_ENTRY(IDataObject) // Cant have empty map so add IDataObject
  34. END_COM_MAP()
  35. protected:
  36. // Item tree related information
  37. // node type related information
  38. virtual const CNodeType* Pnodetype( void ) { return &nodetypeRenameRoot;}
  39. // the display name of the item
  40. virtual const tstring* PstrDisplayName( void ) { return &m_strDisplayName;}
  41. // Get ListView data (GetDisplayInfo calls this).
  42. virtual SC ScGetField(DAT dat, tstring& strField);
  43. // Image list information
  44. virtual LONG Iconid() { return m_uIconIndex; }
  45. virtual LONG OpenIconid() { return m_uIconIndex; }
  46. virtual BOOL FIsContainer( void ) { return TRUE; }
  47. protected:
  48. virtual SC ScGetVerbs(DWORD * pdwVerbs) { *pdwVerbs = vmProperties | vmRefresh | vmRename; return S_OK;}
  49. virtual SC ScOnRename(const tstring& strNewName);
  50. public:
  51. virtual SC ScInit(CBaseSnapin *pSnapin, CColumnInfoEx *pcolinfoex = NULL, INT ccolinfoex = 0, BOOL fIsRoot = FALSE);
  52. public:
  53. // Creates children for the node
  54. virtual SC ScCreateChildren( void );
  55. protected:
  56. tstring m_strDisplayName;
  57. UINT m_uIconIndex;
  58. };
  59. //+-------------------------------------------------------------------
  60. //
  61. // Class: CRenameSnapinLVLeafItem
  62. //
  63. // Purpose: Implements a result pane item.
  64. //
  65. //--------------------------------------------------------------------
  66. class CRenameSnapinLVLeafItem : public CBaseSnapinItem
  67. {
  68. typedef CBaseSnapinItem super;
  69. // Used by CBaseSnapinItem::ScCreateItem, connect this item with its children.
  70. // This is a leaf item so this item acts as its child.
  71. typedef CComObject<CSnapinItem<CRenameSnapinLVLeafItem> > t_item;
  72. typedef CComObject<CSnapinItem<CRenameSnapinLVLeafItem> > t_itemChild;
  73. public:
  74. CRenameSnapinLVLeafItem( void ) : m_hresultItem(NULL) {}
  75. virtual ~CRenameSnapinLVLeafItem( void ) {}
  76. BEGIN_COM_MAP(CRenameSnapinLVLeafItem)
  77. COM_INTERFACE_ENTRY(IDataObject) // Cant have empty map so add IDataObject
  78. END_COM_MAP()
  79. protected:
  80. // Item tree related information
  81. // node type related information
  82. virtual const CNodeType *Pnodetype( void ) {return &nodetypeRenameLVLeafItem;}
  83. // the display name of the item
  84. virtual const tstring* PstrDisplayName( void ) { return &m_strDisplayName; }
  85. // Get ListView data (GetDisplayInfo calls this).
  86. virtual SC ScGetField(DAT dat, tstring& strField);
  87. // Image list information
  88. virtual LONG Iconid() { return m_uIconIndex; }
  89. virtual BOOL FIsContainer( void ) { return FALSE; }
  90. // Context menu support
  91. virtual SnapinMenuItem *Pmenuitem(void);
  92. virtual INT CMenuItem(void);
  93. virtual SC ScCommand(long nCommandID, CComponent *pComponent = NULL);
  94. public:
  95. virtual SC ScInit(CBaseSnapin *pSnapin, CColumnInfoEx *pcolinfoex = NULL, INT ccolinfoex = 0, BOOL fIsRoot = FALSE);
  96. public:
  97. static SC ScCreateLVLeafItem(CRenameRootItem *pitemParent, t_itemChild * pitemPrevious, t_itemChild ** ppitem, BOOL fNew);
  98. virtual SC ScGetVerbs(DWORD * pdwVerbs) { *pdwVerbs = vmProperties | vmRefresh | vmRename; return S_OK;}
  99. private:
  100. SC ScRenameScopeItem();
  101. SC ScRenameResultItem();
  102. SC ScInsertResultItem(CComponent *pComponent);
  103. private:
  104. tstring m_strDisplayName;
  105. UINT m_uIconIndex;
  106. HRESULTITEM m_hresultItem; // NOTE: this caches the HRESULTITEM for the last time this item was inserted. Breaks on multiple views.
  107. IResultData2Ptr m_spResultData2; // NOTE: this caches the IResultData2 for the last time this item was inserted. Breaks on multiple views.
  108. // For context menus
  109. static SnapinMenuItem s_rgmenuitemLVLeafItem[];
  110. static INT s_cmenuitemLVLeafItem;
  111. };
  112. //+-------------------------------------------------------------------
  113. //
  114. // Class: CComponent2Snapin
  115. //
  116. // Purpose: Implements a snapin.
  117. //
  118. //--------------------------------------------------------------------
  119. class CRenameSnapin : public CBaseSnapin
  120. {
  121. // Specify the root node of the snapin.
  122. typedef CComObject<CSnapinItem<CRenameRootItem> > t_itemRoot;
  123. SNAPIN_DECLARE(CRenameSnapin);
  124. public:
  125. CRenameSnapin();
  126. virtual ~CRenameSnapin();
  127. // information about the snapin and root (ie initial) node
  128. virtual BOOL FStandalone() { return TRUE; }
  129. virtual BOOL FIsExtension() { return FALSE; }
  130. virtual BOOL FSupportsIComponent2() {return TRUE;}
  131. virtual LONG IdsDescription(void) {return IDS_RenameSnapinDesc;}
  132. virtual LONG IdsName(void) {return IDS_RenameSnapinName;}
  133. const CSnapinInfo* Psnapininfo() { return &snapininfoRename; }
  134. protected:
  135. // The column header info structures.
  136. static CColumnInfoEx s_colinfo[];
  137. static INT s_colwidths[];
  138. static INT s_ccolinfo;
  139. protected:
  140. virtual CColumnInfoEx* Pcolinfoex(INT icolinfo=0) { return s_colinfo + icolinfo; }
  141. virtual INT &ColumnWidth(INT icolwidth=0) { return s_colwidths[icolwidth]; }
  142. virtual INT Ccolinfoex() { return s_ccolinfo; }
  143. };