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.

139 lines
3.2 KiB

  1. \
  2. #ifndef __TVINTF_H_
  3. #define __TVINTF_H_
  4. /*++
  5. Copyright (c) 1997- Microsoft Corporation
  6. Module Name:
  7. tvintf.h
  8. Abstract:
  9. header file to define interfaces between Device Manager snapin
  10. and TreeView OCX.
  11. Author:
  12. William Hsieh (williamh) created
  13. Revision History:
  14. --*/
  15. // Interface designed for snapin to connect/disconnect, control, retreive
  16. // information to/from the Tree view ocx.
  17. class IDMTVOCX : public IUnknown
  18. {
  19. public: virtual HTREEITEM InsertItem(LPTV_INSERTSTRUCT pis) = 0;
  20. public: virtual HRESULT DeleteItem(HTREEITEM hItem) = 0;
  21. public: virtual HRESULT DeleteAllItems() = 0;
  22. public: virtual HIMAGELIST SetImageList(INT iImage, HIMAGELIST himl) = 0;
  23. public: virtual HRESULT SetItem(TV_ITEM* pitem) = 0;
  24. public: virtual HRESULT Expand(UINT Flags, HTREEITEM htiem) = 0;
  25. public: virtual HRESULT SelectItem(UINT Flags, HTREEITEM hitem) = 0;
  26. public: virtual HRESULT SetStyle(DWORD dwStyle) = 0;
  27. public: virtual HWND GetWindowHandle() = 0;
  28. public: virtual HRESULT GetItem(TV_ITEM* pti) = 0;
  29. public: virtual HTREEITEM GetNextItem(UINT Flags, HTREEITEM htiRef) = 0;
  30. public: virtual HRESULT SelectItem(HTREEITEM hti) = 0;
  31. public: virtual UINT GetCount() = 0;
  32. public: virtual HTREEITEM GetSelectedItem() = 0;
  33. public: virtual HRESULT Connect(IComponent* pIComponent, MMC_COOKIE cookie) = 0;
  34. public: virtual HRESULT SetActiveConnection(MMC_COOKIE cookie) = 0;
  35. public: virtual MMC_COOKIE GetActiveConnection() = 0;
  36. public: virtual HRESULT SetRedraw(BOOL Redraw) = 0;
  37. public: virtual BOOL EnsureVisible(HTREEITEM hitem) = 0;
  38. };
  39. typedef enum tagTvNotifyCode
  40. {
  41. TV_NOTIFY_CODE_CLICK = 0,
  42. TV_NOTIFY_CODE_DBLCLK,
  43. TV_NOTIFY_CODE_RCLICK,
  44. TV_NOTIFY_CODE_RDBLCLK,
  45. TV_NOTIFY_CODE_KEYDOWN,
  46. TV_NOTIFY_CODE_CONTEXTMENU,
  47. TV_NOTIFY_CODE_EXPANDING,
  48. TV_NOTIFY_CODE_EXPANDED,
  49. TV_NOTIFY_CODE_SELCHANGING,
  50. TV_NOTIFY_CODE_SELCHANGED,
  51. TV_NOTIFY_CODE_GETDISPINFO,
  52. TV_NOTIFY_CODE_FOCUSCHANGED,
  53. TV_NOTIFY_CODE_UNKNOWN
  54. } TV_NOTIFY_CODE, *PTV_NOTIFY_CODE;
  55. // interface DECLSPEC_UUID("8e0ba98a-d161-11d0-8353-00a0c90640bf")
  56. class ISnapinCallback : public IUnknown
  57. {
  58. public:
  59. virtual HRESULT STDMETHODCALLTYPE tvNotify(HWND hwndTV, MMC_COOKIE cookie,
  60. TV_NOTIFY_CODE Code,
  61. LPARAM arg, LPARAM param) = 0;
  62. };
  63. extern const IID IID_ISnapinCallback;
  64. extern const IID IID_IDMTVOCX;
  65. template<class ISome>
  66. class SafeInterfacePtr
  67. {
  68. public:
  69. SafeInterfacePtr(ISome* pInterface = NULL)
  70. {
  71. m_pISome = pInterface;
  72. if (m_pISome)
  73. m_pISome->AddRef();
  74. }
  75. ~SafeInterfacePtr()
  76. {
  77. SafeRelease();
  78. }
  79. void SafeRelease()
  80. {
  81. if (m_pISome)
  82. {
  83. m_pISome->Release();
  84. m_pISome = NULL;
  85. }
  86. }
  87. void Attach(ISome* pInterface)
  88. {
  89. ASSERT(!m_pISome);
  90. ASSERT(pInterface);
  91. m_pISome = pInterface;
  92. m_pISome->AddRef();
  93. }
  94. void Detach()
  95. {
  96. ASSERT(m_pISome);
  97. m_pISome->Release();
  98. m_pISome = NULL;
  99. }
  100. ISome* operator->()
  101. {
  102. return m_pISome;
  103. }
  104. ISome& operator*()
  105. {
  106. return *m_pISome;
  107. }
  108. operator ISome*()
  109. {
  110. return m_pISome;
  111. }
  112. ISome ** operator&()
  113. {
  114. return &m_pISome;
  115. }
  116. private:
  117. ISome* m_pISome;
  118. };
  119. #endif //__TVINTF_H_