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.

218 lines
4.9 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (C) Microsoft Corporation, 1999 - 1999
  6. //
  7. // File: rootnode.h
  8. //
  9. //--------------------------------------------------------------------------
  10. // RootNode.h: interface for the CRootNode class.
  11. //
  12. //////////////////////////////////////////////////////////////////////
  13. #if !defined(AFX_ROOTNODE_H__E0573E78_D325_11D1_846C_00104B211BE5__INCLUDED_)
  14. #define AFX_ROOTNODE_H__E0573E78_D325_11D1_846C_00104B211BE5__INCLUDED_
  15. #if _MSC_VER > 1000
  16. #pragma once
  17. #endif // _MSC_VER > 1000
  18. #include "Benefits.h"
  19. #include "Employee.h"
  20. class CRootNode : public CChildrenBenefitsData< CRootNode >
  21. {
  22. public:
  23. BEGIN_SNAPINTOOLBARID_MAP( CRootNode )
  24. END_SNAPINTOOLBARID_MAP()
  25. CRootNode();
  26. //
  27. // Creates the benefits subnodes for the scope pane.
  28. //
  29. BOOL InitializeSubNodes();
  30. //
  31. // Overridden to provide employee name for root node.
  32. //
  33. STDMETHOD( FillData )( CLIPFORMAT cf, LPSTREAM pStream );
  34. //
  35. // Overridden to add new columns to the results
  36. // display.
  37. //
  38. STDMETHOD( OnShowColumn )( IHeaderCtrl* pHeader );
  39. //
  40. // Handles creation of our property pages.
  41. //
  42. STDMETHOD( CreatePropertyPages )(LPPROPERTYSHEETCALLBACK lpProvider,
  43. long handle,
  44. IUnknown* pUnk,
  45. DATA_OBJECT_TYPES type);
  46. //
  47. // Determines if pages should be displayed. This has been
  48. // modified to ensure that we're called by the snap-in manager
  49. // when it's first inserted.
  50. //
  51. STDMETHOD( QueryPagesFor )(DATA_OBJECT_TYPES type)
  52. {
  53. if ( type == CCT_SCOPE || type == CCT_RESULT || type == CCT_SNAPIN_MANAGER )
  54. return S_OK;
  55. return S_FALSE;
  56. }
  57. //
  58. // Ensures that the appropriate verbs are displayed.
  59. //
  60. STDMETHOD( OnSelect )( IConsole* pConsole );
  61. //
  62. // Overridden to call the base class implementation.
  63. //
  64. STDMETHOD(Notify)( MMC_NOTIFY_TYPE event,
  65. long arg,
  66. long param,
  67. IComponentData* pComponentData,
  68. IComponent* pComponent,
  69. DATA_OBJECT_TYPES type)
  70. {
  71. // Add code to handle the different notifications.
  72. // Handle MMCN_SHOW and MMCN_EXPAND to enumerate children items.
  73. // For MMCN_EXPAND you only need to enumerate the scope items
  74. // Use IConsoleNameSpace::InsertItem to insert scope pane items
  75. // Use IResultData::InsertItem to insert result pane item.
  76. HRESULT hr = E_NOTIMPL;
  77. _ASSERTE(pComponentData != NULL || pComponent != NULL);
  78. CComPtr<IConsole> spConsole;
  79. CComQIPtr<IHeaderCtrl, &IID_IHeaderCtrl> spHeader;
  80. if (pComponentData != NULL)
  81. spConsole = ((CBenefits*)pComponentData)->m_spConsole;
  82. else
  83. {
  84. spConsole = ((CBenefitsComponent*)pComponent)->m_spConsole;
  85. spHeader = spConsole;
  86. }
  87. switch (event)
  88. {
  89. case MMCN_SELECT:
  90. hr = OnSelect( spConsole );
  91. break;
  92. case MMCN_SHOW:
  93. // Only setup colums if we're displaying the result pane.
  94. if ( arg == TRUE )
  95. hr = OnShowColumn( spHeader );
  96. break;
  97. case MMCN_EXPAND:
  98. //
  99. // Since the insert item is never called, we don't have a valid
  100. // HSCOPEITEM as you would in sub-nodes. The Expand message is
  101. // intercepted and stored for use later.
  102. //
  103. m_scopeDataItem.ID = param;
  104. hr = OnExpand( event, arg, param, spConsole, type );
  105. break;
  106. case MMCN_ADD_IMAGES:
  107. hr = OnAddImages( event, arg, param, spConsole, type );
  108. break;
  109. }
  110. return hr;
  111. }
  112. //
  113. // Uses the dirty flag to determine whether or not this node
  114. // needs to be persisted.
  115. //
  116. STDMETHOD(IsDirty)()
  117. {
  118. return ( m_fDirty ? S_OK : S_FALSE );
  119. }
  120. //
  121. // Loads the employee information from the stream.
  122. //
  123. STDMETHOD(Load)(LPSTREAM pStm)
  124. {
  125. DWORD dwRead;
  126. pStm->Read( &m_Employee, sizeof( m_Employee ), &dwRead );
  127. _ASSERTE( dwRead == sizeof( m_Employee ) );
  128. return( S_OK );
  129. }
  130. //
  131. // Stores the employee information to the stream and clears
  132. // our dirty flag.
  133. //
  134. STDMETHOD(Save)(LPSTREAM pStm, BOOL fClearDirty)
  135. {
  136. DWORD dwWritten;
  137. pStm->Write( &m_Employee, sizeof( m_Employee ), &dwWritten );
  138. _ASSERTE( dwWritten == sizeof( m_Employee ) );
  139. //
  140. // Clear the dirty flag.
  141. //
  142. if ( fClearDirty )
  143. m_fDirty = FALSE;
  144. return( S_OK );
  145. }
  146. //
  147. // Returns the size of the employee structure.
  148. //
  149. STDMETHOD(GetSizeMax)(ULARGE_INTEGER FAR* pcbSize )
  150. {
  151. pcbSize->LowPart = sizeof( m_Employee );
  152. return( S_OK );
  153. }
  154. //
  155. // Received when a property has changed. This function
  156. // modifies the employee's display text. At a later date,
  157. // it may post this message to its sub-nodes.
  158. //
  159. STDMETHOD( OnPropertyChange )( IConsole* pConsole );
  160. protected:
  161. //
  162. // Simply function to create the display name from the
  163. // employee data.
  164. //
  165. int CreateDisplayName( TCHAR* szBuf );
  166. //
  167. // Called to set the dirty flag for persistence.
  168. //
  169. void SetModified( bool fDirty = true )
  170. {
  171. m_fDirty = fDirty;
  172. }
  173. //
  174. // Contains the the employees entire datastore for this
  175. // sample.
  176. //
  177. CEmployee m_Employee;
  178. //
  179. // Flag set to indicate whether the datastore is "dirty".
  180. //
  181. bool m_fDirty;
  182. };
  183. #endif // !defined(AFX_ROOTNODE_H__E0573E78_D325_11D1_846C_00104B211BE5__INCLUDED_)