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.

196 lines
5.4 KiB

  1. /*--------------------------------------------------------------------------*
  2. *
  3. * Microsoft Windows
  4. * Copyright (C) Microsoft Corporation, 1992 - 1999
  5. *
  6. * File: rsltitem.h
  7. *
  8. * Contents: Interface file for CResultItem
  9. *
  10. * History: 13-Dec-1999 jeffro Created
  11. *
  12. *--------------------------------------------------------------------------*/
  13. #pragma once
  14. #ifndef RSLTITEM_H_INCLUDED
  15. #define RSLTITEM_H_INCLUDED
  16. /*+-------------------------------------------------------------------------*
  17. * CResultItem
  18. *
  19. * This is the class behind the HRESULTITEM. A pointer to this class is
  20. * stored as the item data for each item in a non-virtual list.
  21. *--------------------------------------------------------------------------*/
  22. class CResultItem
  23. {
  24. public:
  25. CResultItem (COMPONENTID id, LPARAM lSnapinData, int nImage);
  26. bool IsScopeItem () const;
  27. COMPONENTID GetOwnerID () const;
  28. LPARAM GetSnapinData () const;
  29. int GetImageIndex () const;
  30. HNODE GetScopeNode () const;
  31. void SetSnapinData (LPARAM lSnapinData);
  32. void SetImageIndex (int nImage);
  33. static HRESULTITEM ToHandle (const CResultItem* pri);
  34. static CResultItem* FromHandle (HRESULTITEM hri);
  35. private:
  36. const COMPONENTID m_id;
  37. int m_nImage;
  38. union
  39. {
  40. HNODE m_hNode; // if IsScopeItem() == true
  41. LPARAM m_lSnapinData; // if IsScopeItem() == false
  42. };
  43. #ifdef DBG
  44. enum { Signature = 0x746c7372 /* "rslt" */ };
  45. const DWORD m_dwSignature;
  46. #endif
  47. };
  48. /*+-------------------------------------------------------------------------*
  49. * CResultItem::CResultItem
  50. *
  51. * Constructs a CResultItem.
  52. *--------------------------------------------------------------------------*/
  53. inline CResultItem::CResultItem (
  54. COMPONENTID id,
  55. LPARAM lSnapinData,
  56. int nImage) :
  57. #ifdef DBG
  58. m_dwSignature (Signature),
  59. #endif
  60. m_id (id),
  61. m_lSnapinData (lSnapinData),
  62. m_nImage (nImage)
  63. {}
  64. /*+-------------------------------------------------------------------------*
  65. * CResultItem::IsScopeItem
  66. *
  67. * Returns true if this CResultItem represents a scope item, false otherwise.
  68. *--------------------------------------------------------------------------*/
  69. inline bool CResultItem::IsScopeItem () const
  70. {
  71. return (m_id == TVOWNED_MAGICWORD);
  72. }
  73. /*+-------------------------------------------------------------------------*
  74. * CResultItem::GetOwnerID
  75. *
  76. * Returns the COMPONENTID for the componenet that owns this CResultItem.
  77. *--------------------------------------------------------------------------*/
  78. inline COMPONENTID CResultItem::GetOwnerID () const
  79. {
  80. return (m_id);
  81. }
  82. /*+-------------------------------------------------------------------------*
  83. * CResultItem::GetSnapinData
  84. *
  85. * Returns the snap-in's LPARAM for this CResultItem.
  86. *--------------------------------------------------------------------------*/
  87. inline LPARAM CResultItem::GetSnapinData () const
  88. {
  89. return (m_lSnapinData);
  90. }
  91. /*+-------------------------------------------------------------------------*
  92. * CResultItem::GetScopeNode
  93. *
  94. * Returns the HNODE for a CResultItem that represents a scope node. If the
  95. * CResultItem does not represent a scope node, NULL is returned.
  96. *--------------------------------------------------------------------------*/
  97. inline HNODE CResultItem::GetScopeNode () const
  98. {
  99. return (IsScopeItem() ? m_hNode : NULL);
  100. }
  101. /*+-------------------------------------------------------------------------*
  102. * CResultItem::GetImageIndex
  103. *
  104. * Returns the image index for a CResultItem.
  105. *--------------------------------------------------------------------------*/
  106. inline int CResultItem::GetImageIndex () const
  107. {
  108. return (m_nImage);
  109. }
  110. /*+-------------------------------------------------------------------------*
  111. * CResultItem::SetSnapinData
  112. *
  113. * Sets the snap-in's LPARAM for the CResultItem.
  114. *--------------------------------------------------------------------------*/
  115. inline void CResultItem::SetSnapinData (LPARAM lSnapinData)
  116. {
  117. m_lSnapinData = lSnapinData;
  118. }
  119. /*+-------------------------------------------------------------------------*
  120. * CResultItem::SetImageIndex
  121. *
  122. * Sets the image index for a CResultItem.
  123. *--------------------------------------------------------------------------*/
  124. inline void CResultItem::SetImageIndex (int nImage)
  125. {
  126. m_nImage = nImage;
  127. }
  128. /*+-------------------------------------------------------------------------*
  129. * CResultItem::ToHandle
  130. *
  131. * Converts a CResultItem to a HRESULTITEM.
  132. *--------------------------------------------------------------------------*/
  133. inline HRESULTITEM CResultItem::ToHandle (const CResultItem* pri)
  134. {
  135. return (reinterpret_cast<HRESULTITEM>(const_cast<CResultItem*>(pri)));
  136. }
  137. /*+-------------------------------------------------------------------------*
  138. * CResultItem::FromHandle
  139. *
  140. * Converts a HRESULTITEM to a CResultItem*. This function cannot use
  141. * dynamic_cast because there are no virtual functions and therefore no
  142. * place to store RTTI.
  143. *--------------------------------------------------------------------------*/
  144. inline CResultItem* CResultItem::FromHandle (HRESULTITEM hri)
  145. {
  146. if ((hri == NULL) || IS_SPECIAL_LVDATA (hri))
  147. return (NULL);
  148. CResultItem* pri = reinterpret_cast<CResultItem*>(hri);
  149. ASSERT (pri->m_dwSignature == Signature);
  150. return (pri);
  151. }
  152. #endif /* RSLTITEM_H_INCLUDED */